fix(telemetry): restore injectCurrentContextToProtobuf decl; re-parent open/establish spans under round; correct childSpan names

Post-review fixes for the SpanGuard scope-leak change:
- SpanGuard.h: restore the injectCurrentContextToProtobuf real-class
  declaration, its #else no-op stub, and the protocol::TraceContext
  forward-declaration dropped during the 3->4 union merge (compile break).
- Re-parent consensus.phase.open and consensus.establish under the round
  span via a new RCLConsensus::Adaptor::roundSpanContext() accessor: the
  round span is now detached, so ambient parenting no longer works; the
  phase spans link explicitly to the captured round context. csf::Peer
  gains a matching no-op accessor so the generic engine still compiles.
- Switch five childSpan(op::X, ctx) sites to the full consensus::span::X
  constants: childSpan(name, ctx) takes the name verbatim, so the suffix-
  only op:: constants emitted short, non-dotted span names.
- TestTelemetry mock: add getConsensusTraceStrategy() override (base pure
  virtual introduced on this branch) so the mock is not abstract.
- validate(): rewrite the trace_context comment to drop attack-surface
  framing and the PR-discussion reference.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Pratik Mankawde
2026-07-20 15:25:15 +01:00
parent c3b1f69ba8
commit 58d4e48679
6 changed files with 86 additions and 24 deletions

View File

@@ -24,6 +24,7 @@
#include <xrpl/beast/utility/WrappedSink.h>
#include <xrpl/json/json_value.h>
#include <xrpl/json/json_writer.h>
#include <xrpl/telemetry/SpanGuard.h>
#include <boost/container/flat_map.hpp>
#include <boost/container/flat_set.hpp>
@@ -700,6 +701,15 @@ struct Peer
{
}
// The generic engine parents its phase spans under the round span via
// this context; the simulator runs without telemetry, so return an
// invalid context and no phase span is created.
static telemetry::SpanContext
roundSpanContext()
{
return {};
}
// Share a message by broadcasting to all connected peers
template <class M>
void