From 6c1d4d92bbc63c76dc058352b617aca8c2a7e8f9 Mon Sep 17 00:00:00 2001 From: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> Date: Wed, 10 Jun 2026 17:28:02 +0100 Subject: [PATCH] fix(telemetry): keep libxrpl SpanGuard test free of xrpld headers The xrpl_tests target links only xrpl.libxrpl and cannot include the xrpld-level ConsensusSpanNames.h / RpcSpanNames.h (CI build failure on ubuntu-gcc-debug-arm64). Revert the test to underscore-form attribute literals, restore the SpanNames.h include for seg::consensus, and drop the now-unused tests.libxrpl -> xrpld.* levelization entries. Co-Authored-By: Claude Opus 4.8 --- .../scripts/levelization/results/ordering.txt | 2 - .../libxrpl/telemetry/SpanGuardFactory.cpp | 43 +++++++++++-------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/.github/scripts/levelization/results/ordering.txt b/.github/scripts/levelization/results/ordering.txt index 102387de06..d091753158 100644 --- a/.github/scripts/levelization/results/ordering.txt +++ b/.github/scripts/levelization/results/ordering.txt @@ -207,8 +207,6 @@ test.unit_test > xrpl.protocol tests.libxrpl > xrpl.basics tests.libxrpl > xrpl.config tests.libxrpl > xrpl.core -tests.libxrpl > xrpld.consensus -tests.libxrpl > xrpld.rpc tests.libxrpl > xrpl.json tests.libxrpl > xrpl.ledger tests.libxrpl > xrpl.net diff --git a/src/tests/libxrpl/telemetry/SpanGuardFactory.cpp b/src/tests/libxrpl/telemetry/SpanGuardFactory.cpp index 7f2df65485..0d3802df8b 100644 --- a/src/tests/libxrpl/telemetry/SpanGuardFactory.cpp +++ b/src/tests/libxrpl/telemetry/SpanGuardFactory.cpp @@ -1,13 +1,12 @@ -#include -#include - #include +#include #include #include #include #include +#include #include using namespace xrpl; @@ -31,8 +30,12 @@ TEST(SpanGuardFactory, category_span_returns_null_when_disabled) auto span = SpanGuard::span(TraceCategory::Rpc, "rpc", "test"); EXPECT_FALSE(span); - span.setAttribute(rpc_span::attr::command, "test"); - span.setAttribute(rpc_span::attr::rpcStatus, rpc_span::val::success); + // Attribute keys use the underscore convention for span attributes (the + // dotted xrpl.. form is reserved for resource attributes). The + // canonical constants live in the xrpld-level *SpanNames.h headers, which a + // libxrpl test cannot include, so the keys are written as literals here. + span.setAttribute("command", "test"); + span.setAttribute("rpc_status", "success"); } TEST(SpanGuardFactory, child_span_null_when_no_parent) @@ -86,24 +89,26 @@ TEST(SpanGuardFactory, discard_safe_on_null) TEST(SpanGuardFactory, consensus_close_time_attributes) { - // Verify the consensus attribute pattern compiles and - // doesn't crash with null SpanGuard. - namespace cs = consensus::span; + // Verify the consensus attribute pattern compiles and doesn't crash with a + // null SpanGuard. Attribute keys/values use the underscore convention; the + // canonical consensus::span constants are defined in the xrpld-level + // ConsensusSpanNames.h, which a libxrpl test cannot include, so the keys are + // written as literals here. { auto span = telemetry::SpanGuard::span( - telemetry::TraceCategory::Consensus, telemetry::seg::consensus, cs::op::acceptApply); - span.setAttribute(cs::attr::ledgerSeq, static_cast(42)); - span.setAttribute(cs::attr::closeTime, static_cast(780000000)); - span.setAttribute(cs::attr::closeTimeCorrect, true); - span.setAttribute(cs::attr::closeResolutionMs, static_cast(30000)); - span.setAttribute(cs::attr::consensusState, cs::val::finished); - span.setAttribute(cs::attr::proposing, true); - span.setAttribute(cs::attr::roundTimeMs, static_cast(3500)); + telemetry::TraceCategory::Consensus, telemetry::seg::consensus, "accept.apply"); + span.setAttribute("ledger_seq", static_cast(42)); + span.setAttribute("close_time", static_cast(780000000)); + span.setAttribute("close_time_correct", true); + span.setAttribute("close_resolution_ms", static_cast(30000)); + span.setAttribute("consensus_state", std::string("finished")); + span.setAttribute("proposing", true); + span.setAttribute("round_time_ms", static_cast(3500)); } { auto span = telemetry::SpanGuard::span( - telemetry::TraceCategory::Consensus, telemetry::seg::consensus, cs::op::acceptApply); - span.setAttribute(cs::attr::closeTimeCorrect, false); - span.setAttribute(cs::attr::consensusState, cs::val::movedOn); + telemetry::TraceCategory::Consensus, telemetry::seg::consensus, "accept.apply"); + span.setAttribute("close_time_correct", false); + span.setAttribute("consensus_state", std::string("moved_on")); } }