From d865a266b5fb4f89021fd2ba00155cf11ceb10f2 Mon Sep 17 00:00:00 2001 From: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> Date: Wed, 22 Jul 2026 16:20:16 +0100 Subject: [PATCH 1/2] fix(telemetry): clang-tidy naming + include-cleaner in DeterministicIdGenerator - Rename file-local thread_local globals to the .clang-tidy convention (GlobalVariablePrefix "g" + CamelCase), keeping the Tls marker: tlsPendingTraceId -> gTlsPendingTraceId, tlsPendingConsumed -> gTlsPendingConsumed. - Add direct includes for opentelemetry trace_id.h / span_id.h (header uses TraceId/SpanId in signatures) and sdk/trace/id_generator.h (.cpp references IdGenerator directly) to satisfy misc-include-cleaner. Both verified clean with clang-tidy against a telemetry-enabled compile DB. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../xrpl/telemetry/DeterministicIdGenerator.h | 2 ++ .../telemetry/DeterministicIdGenerator.cpp | 23 ++++++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/include/xrpl/telemetry/DeterministicIdGenerator.h b/include/xrpl/telemetry/DeterministicIdGenerator.h index b0ec492e55..ba351d233e 100644 --- a/include/xrpl/telemetry/DeterministicIdGenerator.h +++ b/include/xrpl/telemetry/DeterministicIdGenerator.h @@ -3,6 +3,8 @@ #ifdef XRPL_ENABLE_TELEMETRY #include +#include +#include #include #include diff --git a/src/libxrpl/telemetry/DeterministicIdGenerator.cpp b/src/libxrpl/telemetry/DeterministicIdGenerator.cpp index 2a2c8c65ec..ff54307d1b 100644 --- a/src/libxrpl/telemetry/DeterministicIdGenerator.cpp +++ b/src/libxrpl/telemetry/DeterministicIdGenerator.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -32,14 +33,14 @@ namespace { * Trace_id pinned by PendingTraceId, consumed by GenerateTraceId(). File-local * and thread-local, so it is set and read on the same thread with no locking. */ -thread_local std::optional> tlsPendingTraceId; +thread_local std::optional> gTlsPendingTraceId; /** * True once GenerateTraceId() has consumed the pending id. ~PendingTraceId * asserts on it to catch a forced-root span that never reached the SDK root * branch. */ -thread_local bool tlsPendingConsumed = false; +thread_local bool gTlsPendingConsumed = false; } // namespace @@ -52,11 +53,11 @@ DeterministicIdGenerator::DeterministicIdGenerator() opentelemetry::trace::TraceId DeterministicIdGenerator::GenerateTraceId() noexcept { - if (tlsPendingTraceId) + if (gTlsPendingTraceId) { - auto const id = *tlsPendingTraceId; - tlsPendingTraceId.reset(); - tlsPendingConsumed = true; + auto const id = *gTlsPendingTraceId; + gTlsPendingTraceId.reset(); + gTlsPendingConsumed = true; return opentelemetry::trace::TraceId( opentelemetry::nostd::span(id.data(), 16)); } @@ -71,8 +72,8 @@ DeterministicIdGenerator::GenerateSpanId() noexcept PendingTraceId::PendingTraceId(std::array const& id) noexcept { - tlsPendingTraceId = id; - tlsPendingConsumed = false; + gTlsPendingTraceId = id; + gTlsPendingConsumed = false; } PendingTraceId::~PendingTraceId() noexcept @@ -81,10 +82,10 @@ PendingTraceId::~PendingTraceId() noexcept // via GenerateTraceId(). If not, the SDK took a different branch than the // caller forced — a bug — so fail loudly in debug/test builds. XRPL_ASSERT( - tlsPendingConsumed, + gTlsPendingConsumed, "xrpl::telemetry::PendingTraceId : deterministic trace_id was not consumed"); - tlsPendingTraceId.reset(); // never leak, even in release - tlsPendingConsumed = false; + gTlsPendingTraceId.reset(); // never leak, even in release + gTlsPendingConsumed = false; } } // namespace xrpl::telemetry From f9579b73561541a47af088ba6c61575e53bb72ce Mon Sep 17 00:00:00 2001 From: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> Date: Wed, 22 Jul 2026 16:20:44 +0100 Subject: [PATCH 2/2] fix(telemetry): drop redundant SpanNames.h include from Consensus.h Consensus.h includes ConsensusSpanNames.h, which already includes SpanNames.h (it is built on StaticStr/join()). Consensus.h uses no base SpanNames.h symbols directly, so misc-include-cleaner flags the direct include as unused. Remove it; SpanNames.h stays reachable transitively. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/xrpld/consensus/Consensus.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/xrpld/consensus/Consensus.h b/src/xrpld/consensus/Consensus.h index 86987d9bc0..4e890aca91 100644 --- a/src/xrpld/consensus/Consensus.h +++ b/src/xrpld/consensus/Consensus.h @@ -15,7 +15,6 @@ #include #include #include -#include #include #include