Merge branch 'pratik/otel-phase8-log-correlation' into pratik/otel-phase9-metric-gap-fill

This commit is contained in:
Pratik Mankawde
2026-06-09 19:12:17 +01:00
13 changed files with 137 additions and 241 deletions

View File

@@ -45,11 +45,16 @@
Usage examples:
Span names and attribute keys come from per-module `*SpanNames.h`
headers (e.g. RpcSpanNames.h, TxSpanNames.h) as typed compile-time
constants — never raw string literals — so the naming spec is
enforced at the call site and dashboards stay in sync.
1. Basic RPC tracing (factory method with category):
@code
#include <xrpld/rpc/detail/RpcSpanNames.h>
using namespace xrpl::telemetry;
// At the call site (constants from RpcSpanNames.h):
auto span = SpanGuard::span(
TraceCategory::Rpc, rpc_span::prefix::command, "submit");
span.setAttribute(rpc_span::attr::command, "submit");
@@ -71,19 +76,22 @@
3. Cross-thread context propagation:
@code
#include <xrpld/consensus/ConsensusSpanNames.h>
using namespace xrpl::telemetry;
// Thread A: create span and capture context
auto span = SpanGuard::span(
TraceCategory::Consensus, seg::consensus, "round");
TraceCategory::Consensus, seg::consensus, consensus::span::op::round);
auto ctx = span.captureContext();
// Thread B: create child with captured context
auto child = SpanGuard::childSpan("consensus.accept", ctx);
auto child = SpanGuard::childSpan(consensus::span::accept, ctx);
@endcode
4. Conditional check (rarely needed — methods are no-ops on null):
@code
auto span = SpanGuard::span(
TraceCategory::Rpc, rpc_span::prefix::rpc, "request");
TraceCategory::Rpc, rpc_span::prefix::rpc, rpc_span::op::httpRequest);
if (span) {
// expensive attribute computation only when active
span.setAttribute(rpc_span::attr::requestPayloadSize, computeSize());
@@ -93,7 +101,7 @@
5. Tail-based filtering via discard():
@code
auto span = SpanGuard::span(
TraceCategory::Transactions, seg::tx, "process");
TraceCategory::Transactions, tx_span::prefix::tx, tx_span::op::process);
auto result = preflight(tx);
if (result != tesSUCCESS) {
span.discard(); // drop span, never exported

View File

@@ -172,13 +172,16 @@ public:
whenever tlsClientCertPath is set. */
std::string tlsClientKeyPath;
/** Head-based sampling ratio in [0.0, 1.0]. 1.0 = trace everything.
This is a head-based (pre-decision) sampler using
TraceIdRatioBasedSampler — the decision to record or drop a
trace is made before the root span starts. For post-hoc
(tail-based) filtering, see SpanGuard::discard().
/** Head-based sampling ratio. Intentionally fixed at 1.0 (sample
everything) and NOT read from config. A per-node ratio would let
nodes make divergent keep/drop decisions for the same distributed
trace, producing broken/partial traces. The ratio sampler is wrapped
in a ParentBasedSampler (see Telemetry.cpp) so spans inheriting a
remote parent honor the upstream sampled flag. Volume reduction is
delegated to the collector's tail sampling; for node-local post-hoc
dropping see SpanGuard::discard().
*/
double samplingRatio = 1.0;
double const samplingRatio = 1.0;
/** Maximum number of spans per batch export. */
std::uint32_t batchSize = 512;