feat(telemetry): add tx.transactor span for per-transactor execution timing

Wraps Transactor::operator() with a span that captures tx_type,
ter_result, and applied. This is the universal dispatch point — every
transaction flows through it, giving per-type latency breakdown.

Adds libxrpl.tx > xrpl.telemetry levelization dependency.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Pratik Mankawde
2026-06-03 16:32:16 +01:00
parent 8dd5ac55e8
commit a13a858112
3 changed files with 20 additions and 3 deletions

View File

@@ -50,6 +50,7 @@ libxrpl.tx > xrpl.json
libxrpl.tx > xrpl.ledger
libxrpl.tx > xrpl.protocol
libxrpl.tx > xrpl.server
libxrpl.tx > xrpl.telemetry
libxrpl.tx > xrpl.tx
test.app > test.jtx
test.app > test.unit_test

View File

@@ -189,9 +189,6 @@ target_link_libraries(
xrpl.libxrpl.conditions
)
add_module(xrpl tx)
target_link_libraries(xrpl.libxrpl.tx PUBLIC xrpl.libxrpl.ledger)
# Telemetry module — OpenTelemetry distributed tracing support.
# Sources: include/xrpl/telemetry/ (headers), src/libxrpl/telemetry/ (impl).
# When telemetry=ON, links the Conan-provided umbrella target
@@ -209,6 +206,12 @@ if(telemetry)
)
endif()
add_module(xrpl tx)
target_link_libraries(
xrpl.libxrpl.tx
PUBLIC xrpl.libxrpl.ledger xrpl.libxrpl.telemetry
)
add_library(xrpl.libxrpl)
set_target_properties(xrpl.libxrpl PROPERTIES OUTPUT_NAME xrpl)

View File

@@ -34,9 +34,12 @@
#include <xrpl/protocol/SystemParameters.h>
#include <xrpl/protocol/TER.h>
#include <xrpl/protocol/TxFlags.h>
#include <xrpl/protocol/TxFormats.h>
#include <xrpl/protocol/TxMeta.h>
#include <xrpl/protocol/XRPAmount.h>
#include <xrpl/server/LoadFeeTrack.h>
#include <xrpl/telemetry/SpanGuard.h>
#include <xrpl/telemetry/SpanNames.h>
#include <xrpl/tx/ApplyContext.h>
#include <xrpl/tx/SignerEntries.h>
#include <xrpl/tx/apply.h>
@@ -1193,6 +1196,13 @@ Transactor::checkInvariants(TER result, XRPAmount fee)
ApplyResult
Transactor::operator()()
{
auto span = telemetry::SpanGuard::span(
telemetry::TraceCategory::Transactions,
telemetry::seg::tx,
telemetry::makeStr("transactor"));
if (auto const* fmt = TxFormats::getInstance().findByType(ctx_.tx.getTxnType()))
span.setAttribute("tx_type", fmt->getName().c_str());
JLOG(j_.trace()) << "apply: " << ctx_.tx.getTransactionID();
// These global updates really should have been for every Transaction
@@ -1419,6 +1429,9 @@ Transactor::operator()()
JLOG(j_.trace()) << (applied ? "applied " : "not applied ") << transToken(result);
span.setAttribute("ter_result", transToken(result).c_str());
span.setAttribute("applied", applied);
return {result, applied, metadata};
}