diff --git a/OpenTelemetryPlan/06-implementation-phases.md b/OpenTelemetryPlan/06-implementation-phases.md index 794126635b..8aba7836ad 100644 --- a/OpenTelemetryPlan/06-implementation-phases.md +++ b/OpenTelemetryPlan/06-implementation-phases.md @@ -278,9 +278,11 @@ See [Phase4_taskList.md](./Phase4_taskList.md) for full task details. **Objective**: Wire `TraceContextPropagator` for P2P messages (proposals, validations) to enable true distributed tracing between nodes. -**Status**: Design documented, NOT implemented. Protobuf fields (field 1001) -and `TraceContextPropagator` free functions exist. Wiring deferred until Phase 4a is -validated in a multi-node environment. +**Status**: Partially implemented. Send-side injection (proposals and +validations) and receive-side extraction (`consensus.{proposal,validation}. +receive` spans parented on the sender's context) are wired in Phase 4a. +Remaining Phase 4b work: relay spans in `share(RCLCxPeerPos)` and multi-node +validation of the propagation path. **Prerequisites**: Phase 4a complete and validated. diff --git a/OpenTelemetryPlan/Phase4_taskList.md b/OpenTelemetryPlan/Phase4_taskList.md index 9973331651..028a7a7e85 100644 --- a/OpenTelemetryPlan/Phase4_taskList.md +++ b/OpenTelemetryPlan/Phase4_taskList.md @@ -95,10 +95,16 @@ - Creates `consensus.proposal.receive` span - Sets `trusted` attribute (bool) -**Not implemented** (deferred to Phase 4b — cross-node propagation): +**Done here** (cross-node propagation, send + receive): -- `consensus.proposal.relay` span in `share(RCLCxPeerPos)` — requires trace context injection -- Trace context injection/extraction for `TMProposeSet::trace_context` +- Trace context injection for `TMProposeSet::trace_context` in `propose()` +- Receive-side extraction in `PeerImp::onMessage(TMProposeSet)` via + `telemetry::proposalReceiveSpan()` (parents the receive span on the + sender's context when a valid `trace_context` is present) + +**Not implemented** (deferred to Phase 4b): + +- `consensus.proposal.relay` span in `share(RCLCxPeerPos)` **Key modified files**: diff --git a/docker/telemetry/grafana/provisioning/datasources/tempo.yaml b/docker/telemetry/grafana/provisioning/datasources/tempo.yaml index 3e4065ccb9..a59db8a336 100644 --- a/docker/telemetry/grafana/provisioning/datasources/tempo.yaml +++ b/docker/telemetry/grafana/provisioning/datasources/tempo.yaml @@ -144,12 +144,12 @@ datasources: tag: close_time_correct operator: "=" scope: span - type: dynamic + type: static - id: consensus-state tag: consensus_state operator: "=" scope: span - type: dynamic + type: static - id: consensus-close-resolution tag: close_resolution_ms operator: "=" diff --git a/src/xrpld/app/consensus/RCLConsensus.cpp b/src/xrpld/app/consensus/RCLConsensus.cpp index 51cc8bcb94..978d9c9ee2 100644 --- a/src/xrpld/app/consensus/RCLConsensus.cpp +++ b/src/xrpld/app/consensus/RCLConsensus.cpp @@ -1260,8 +1260,25 @@ RCLConsensus::Adaptor::startRoundTracing(RCLCxLedger const& prevLgr) telemetry::SpanContext const* const link = prevRoundSpanContext_.isValid() ? &prevRoundSpanContext_ : nullptr; - if (strategy == "deterministic") + if (strategy == "attribute") { + // Non-deterministic strategy: each node gets a random trace_id, + // correlated via the consensus_ledger_id attribute rather than a + // shared trace_id. Still attach a follows-from link to the prior + // round so consecutive rounds stay navigable. linkedSpan is not + // TraceCategory-aware, so gate it explicitly to match the gating + // of the hashSpan/span factories used below. + if (link != nullptr && app_.getTelemetry().shouldTraceConsensus()) + roundSpan_.emplace(telemetry::SpanGuard::linkedSpan(cs::round, *link)); + else + roundSpan_.emplace( + telemetry::SpanGuard::span( + telemetry::TraceCategory::Consensus, telemetry::seg::consensus, cs::op::round)); + } + else + { + // "deterministic" (the default): derive the trace_id from the previous + // ledger hash so all validators tracing the same round share one trace. roundSpan_.emplace( telemetry::SpanGuard::hashSpan( telemetry::TraceCategory::Consensus, @@ -1270,12 +1287,6 @@ RCLConsensus::Adaptor::startRoundTracing(RCLCxLedger const& prevLgr) prevLgr.id().kBytes, link)); } - else - { - roundSpan_.emplace( - telemetry::SpanGuard::span( - telemetry::TraceCategory::Consensus, telemetry::seg::consensus, cs::op::round)); - } if (!*roundSpan_) return;