refactor(telemetry): remove consensus tracing from phase-3

Phase-3 (PR #6425) is scoped to transaction tracing only; consensus
tracing belongs to phase-4 (PR #6426). The previous commit on this
branch removed the namespace/attribute scaffolding c6c019ed8b leaked
into phase-3, but phase-3 still carried the consensus span construction
and trace-context propagation introduced in earlier commits
(61cb1faf8f, 93bed03d8d). Move that out too so phase-3 creates and
propagates no consensus spans of any kind.

Removed:
  - src/xrpld/telemetry/ConsensusReceiveTracing.h (deleted; phase-4
    owns it).
  - PeerImp.cpp: remove the std::make_shared<SpanGuard>(
    proposalReceiveSpan(...))/validationReceiveSpan(...) constructions
    in onMessage(TMProposeSet)/onMessage(TMValidation), drop the
    sp = std::move(span) lambda captures, and drop the
    #include <xrpld/telemetry/ConsensusReceiveTracing.h>.
  - RCLConsensus.cpp: drop the two telemetry::injectToProtobuf() blocks
    that injected the active trace context into TMProposeSet (in
    Adaptor::propose, after addSuppression) and TMValidation (in
    Adaptor::validate, around the broadcast call). Drop the now-unused
    #include of TraceContextPropagator.h and the
    XRPL_ENABLE_TELEMETRY-gated include of
    opentelemetry/context/runtime_context.h.
  - TraceContextPropagator.h: update file-level @see comment to drop
    the ConsensusReceiveTracing.h reference and to scope the
    "wired into the P2P message flow via PropagationHelpers.h"
    sentence to TMTransaction only.
  - PropagationHelpers.h: replace the
    @see ConsensusReceiveTracing.h cross-reference with
    @see TxTracing.h.

Inert consensus metadata (TraceCategory::Consensus enum value,
seg::consensus constant, isCategoryEnabled/categoryToSpanKind switch
arms, the SpanGuard.h doc-comment example) is intentionally preserved
on phase-3: nothing references it after this commit, but phase-4
needs it and removing it would widen the phase-3 -> phase-4 merge
surface for no benefit.

Verified via git grep: no remaining phase-3 references to
proposalReceiveSpan, validationReceiveSpan, ConsensusReceiveTracing,
consensus_span::, consensus.proposal, or consensus.validation.

Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com>
This commit is contained in:
Pratik Mankawde
2026-05-28 17:01:46 +01:00
parent c9521b97fe
commit d6b101069e
5 changed files with 5 additions and 176 deletions

View File

@@ -5,13 +5,12 @@
Provides serialization/deserialization of OTel trace context to/from Provides serialization/deserialization of OTel trace context to/from
Protocol Buffer TraceContext messages (P2P cross-node propagation). Protocol Buffer TraceContext messages (P2P cross-node propagation).
Wired into the P2P message flow via PropagationHelpers.h for Wired into the P2P message flow via PropagationHelpers.h for
TMTransaction, TMProposeSet, and TMValidation messages. TMTransaction messages.
Only compiled when XRPL_ENABLE_TELEMETRY is defined. Only compiled when XRPL_ENABLE_TELEMETRY is defined.
@see PropagationHelpers.h (high-level inject helpers), @see PropagationHelpers.h (high-level inject helpers),
TxTracing.h (transaction receive-side extraction), TxTracing.h (transaction receive-side extraction).
ConsensusReceiveTracing.h (proposal/validation receive-side).
*/ */
#ifdef XRPL_ENABLE_TELEMETRY #ifdef XRPL_ENABLE_TELEMETRY

View File

@@ -62,14 +62,9 @@
#include <xrpl/shamap/SHAMapItem.h> #include <xrpl/shamap/SHAMapItem.h>
#include <xrpl/shamap/SHAMapMissingNode.h> #include <xrpl/shamap/SHAMapMissingNode.h>
#include <xrpl/shamap/SHAMapTreeNode.h> #include <xrpl/shamap/SHAMapTreeNode.h>
#include <xrpl/telemetry/TraceContextPropagator.h> // IWYU pragma: keep
#include <boost/smart_ptr/intrusive_ptr.hpp> #include <boost/smart_ptr/intrusive_ptr.hpp>
#ifdef XRPL_ENABLE_TELEMETRY
#include <opentelemetry/context/runtime_context.h>
#endif
#include <xrpl.pb.h> #include <xrpl.pb.h>
#include <algorithm> #include <algorithm>
@@ -266,16 +261,6 @@ RCLConsensus::Adaptor::propose(RCLCxPeerPos::Proposal const& proposal)
app_.getHashRouter().addSuppression(suppression); app_.getHashRouter().addSuppression(suppression);
// Inject the current thread's active span context (e.g. the
// consensus round span from Phase 4) so receiving peers can link
// their proposal.receive span as a child of this trace.
#ifdef XRPL_ENABLE_TELEMETRY
{
auto ctx = opentelemetry::context::RuntimeContext::GetCurrent();
telemetry::injectToProtobuf(ctx, *prop.mutable_trace_context());
}
#endif
app_.getOverlay().broadcast(prop); app_.getOverlay().broadcast(prop);
} }
@@ -896,14 +881,6 @@ RCLConsensus::Adaptor::validate(RCLCxLedger const& ledger, RCLTxSet const& txns,
// Broadcast to all our peers: // Broadcast to all our peers:
protocol::TMValidation val; protocol::TMValidation val;
val.set_validation(serialized.data(), serialized.size()); val.set_validation(serialized.data(), serialized.size());
// Inject the current thread's active span context so receiving
// peers can link their validation.receive span as a child.
#ifdef XRPL_ENABLE_TELEMETRY
{
auto ctx = opentelemetry::context::RuntimeContext::GetCurrent();
telemetry::injectToProtobuf(ctx, *val.mutable_trace_context());
}
#endif
app_.getOverlay().broadcast(val); app_.getOverlay().broadcast(val);
// Publish to all our subscribers: // Publish to all our subscribers:

View File

@@ -22,7 +22,6 @@
#include <xrpld/overlay/detail/Tuning.h> #include <xrpld/overlay/detail/Tuning.h>
#include <xrpld/peerfinder/PeerfinderManager.h> #include <xrpld/peerfinder/PeerfinderManager.h>
#include <xrpld/peerfinder/Slot.h> #include <xrpld/peerfinder/Slot.h>
#include <xrpld/telemetry/ConsensusReceiveTracing.h>
#include <xrpld/telemetry/TxTracing.h> #include <xrpld/telemetry/TxTracing.h>
#include <xrpl/basics/Log.h> #include <xrpl/basics/Log.h>
@@ -1975,17 +1974,9 @@ PeerImp::onMessage(std::shared_ptr<protocol::TMProposeSet> const& m)
app_.getTimeKeeper().closeTime(), app_.getTimeKeeper().closeTime(),
calcNodeID(app_.getValidatorManifests().getMasterKey(publicKey))}); calcNodeID(app_.getValidatorManifests().getMasterKey(publicKey))});
// Create a receive span that links to the sender's trace context
// (if propagated). shared_ptr keeps it alive across the job boundary.
auto span = std::make_shared<telemetry::SpanGuard>(telemetry::proposalReceiveSpan(set));
span->setAttribute("xrpl.consensus.trusted", isTrusted);
span->setAttribute("xrpl.consensus.round", static_cast<int64_t>(set.proposeseq()));
std::weak_ptr<PeerImp> const weak = shared_from_this(); std::weak_ptr<PeerImp> const weak = shared_from_this();
app_.getJobQueue().addJob( app_.getJobQueue().addJob(
isTrusted ? jtPROPOSAL_t : jtPROPOSAL_ut, isTrusted ? jtPROPOSAL_t : jtPROPOSAL_ut, "checkPropose", [weak, isTrusted, m, proposal]() {
"checkPropose",
[weak, isTrusted, m, proposal, sp = std::move(span)]() {
if (auto peer = weak.lock()) if (auto peer = weak.lock())
peer->checkPropose(isTrusted, m, proposal); peer->checkPropose(isTrusted, m, proposal);
}); });
@@ -2560,17 +2551,6 @@ PeerImp::onMessage(std::shared_ptr<protocol::TMValidation> const& m)
return; return;
} }
// Create a receive span that links to the sender's trace context
// (if propagated). shared_ptr keeps it alive across the job boundary.
auto span = std::make_shared<telemetry::SpanGuard>(telemetry::validationReceiveSpan(*m));
span->setAttribute("xrpl.consensus.trusted", isTrusted);
if (val->isFieldPresent(sfLedgerSequence))
{
span->setAttribute(
"xrpl.consensus.ledger.seq",
static_cast<int64_t>(val->getFieldU32(sfLedgerSequence)));
}
if (!isTrusted && (tracking_.load() == Tracking::diverged)) if (!isTrusted && (tracking_.load() == Tracking::diverged))
{ {
JLOG(p_journal_.debug()) << "Dropping untrusted validation from diverged peer"; JLOG(p_journal_.debug()) << "Dropping untrusted validation from diverged peer";
@@ -2581,9 +2561,7 @@ PeerImp::onMessage(std::shared_ptr<protocol::TMValidation> const& m)
std::weak_ptr<PeerImp> const weak = shared_from_this(); std::weak_ptr<PeerImp> const weak = shared_from_this();
app_.getJobQueue().addJob( app_.getJobQueue().addJob(
isTrusted ? jtVALIDATION_t : jtVALIDATION_ut, isTrusted ? jtVALIDATION_t : jtVALIDATION_ut, name, [weak, val, m, key]() {
name,
[weak, val, m, key, sp = std::move(span)]() {
if (auto peer = weak.lock()) if (auto peer = weak.lock())
peer->checkValidation(val, key, m); peer->checkValidation(val, key, m);
}); });

View File

@@ -1,125 +0,0 @@
#pragma once
/** Helper functions for creating consensus receive trace spans.
*
* Encapsulates the logic for creating SpanGuard instances for incoming
* proposal and validation messages with optional protobuf parent
* extraction. When the incoming message carries a TraceContext with a
* valid span_id, the receive span is created as a child of the
* sender's span, enabling cross-node trace correlation.
*
* Dependency diagram:
*
* protocol::TMProposeSet / TMValidation
* |
* v
* proposalReceiveSpan() / validationReceiveSpan()
* |
* +--- has trace_context? ----+
* | yes | no
* v v
* SpanGuard::span() with SpanGuard::span()
* extracted parent context (standalone span)
*
* When XRPL_ENABLE_TELEMETRY is not defined, the functions return
* no-op SpanGuard instances (zero overhead, zero dependencies).
*
* Usage:
* @code
* // In PeerImp::onMessage(TMProposeSet):
* auto span = telemetry::proposalReceiveSpan(*m);
* span.setAttribute(...);
* @endcode
*
* @note These span names use inline string_view literals. When
* ConsensusSpanNames.h (from Phase 4) is available, callers should
* migrate to using the constexpr constants defined there.
*/
#include <xrpl/proto/xrpl.pb.h>
#include <xrpl/telemetry/SpanGuard.h>
namespace xrpl::telemetry {
// Inline span name constants for consensus receive spans.
// Phase 4 will provide these via ConsensusSpanNames.h; these are
// temporary definitions for the propagation infrastructure.
namespace detail {
inline constexpr std::string_view proposalReceiveName = "consensus.proposal.receive";
inline constexpr std::string_view validationReceiveName = "consensus.validation.receive";
} // namespace detail
/** Create a "consensus.proposal.receive" span for an incoming proposal.
*
* If the message carries a TraceContext with a valid span_id, the
* receive span is created with the sender's context as parent.
* Otherwise a standalone span is created.
*
* @param msg The incoming TMProposeSet protobuf message.
* @return An active SpanGuard, or a null guard if tracing is disabled.
*/
inline SpanGuard
proposalReceiveSpan([[maybe_unused]] protocol::TMProposeSet const& msg)
{
#ifdef XRPL_ENABLE_TELEMETRY
if (msg.has_trace_context())
{
auto const& tc = msg.trace_context();
if (tc.has_span_id() && tc.span_id().size() == 8 && tc.has_trace_id() &&
tc.trace_id().size() == 16)
{
// Create a child span using the sender's trace_id and
// span_id as parent. Use hashSpan with the sender's
// trace_id so the receiving span shares the same trace.
return SpanGuard::hashSpan(
TraceCategory::Consensus,
detail::proposalReceiveName,
reinterpret_cast<std::uint8_t const*>(tc.trace_id().data()),
tc.trace_id().size(),
reinterpret_cast<std::uint8_t const*>(tc.span_id().data()),
tc.span_id().size(),
tc.has_trace_flags() ? static_cast<std::uint8_t>(tc.trace_flags())
: std::uint8_t{0});
}
}
#endif
// No propagated context — create a standalone span.
return SpanGuard::span(TraceCategory::Consensus, "consensus", "proposal.receive");
}
/** Create a "consensus.validation.receive" span for an incoming validation.
*
* If the message carries a TraceContext with a valid span_id, the
* receive span is created with the sender's context as parent.
* Otherwise a standalone span is created.
*
* @param msg The incoming TMValidation protobuf message.
* @return An active SpanGuard, or a null guard if tracing is disabled.
*/
inline SpanGuard
validationReceiveSpan([[maybe_unused]] protocol::TMValidation const& msg)
{
#ifdef XRPL_ENABLE_TELEMETRY
if (msg.has_trace_context())
{
auto const& tc = msg.trace_context();
if (tc.has_span_id() && tc.span_id().size() == 8 && tc.has_trace_id() &&
tc.trace_id().size() == 16)
{
return SpanGuard::hashSpan(
TraceCategory::Consensus,
detail::validationReceiveName,
reinterpret_cast<std::uint8_t const*>(tc.trace_id().data()),
tc.trace_id().size(),
reinterpret_cast<std::uint8_t const*>(tc.span_id().data()),
tc.span_id().size(),
tc.has_trace_flags() ? static_cast<std::uint8_t>(tc.trace_flags())
: std::uint8_t{0});
}
}
#endif
// No propagated context — create a standalone span.
return SpanGuard::span(TraceCategory::Consensus, "consensus", "validation.receive");
}
} // namespace xrpl::telemetry

View File

@@ -25,7 +25,7 @@
* overlay.relay(txID, tx, toSkip); * overlay.relay(txID, tx, toSkip);
* @endcode * @endcode
* *
* @see ConsensusReceiveTracing.h for receive-side extraction helpers. * @see TxTracing.h for receive-side extraction helpers.
* @see TraceContextPropagator.h for low-level OTel context serialization. * @see TraceContextPropagator.h for low-level OTel context serialization.
*/ */