From 07bc6d2ce72fb8f9327db74694930840d00b75bd Mon Sep 17 00:00:00 2001 From: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> Date: Fri, 24 Jul 2026 15:32:41 +0100 Subject: [PATCH 1/2] refactor(telemetry): name trace_id/span_id literals and hex widths in Log Replace the raw "trace_id="/" span_id=" prefix literals and the bare 32/16 hex-width magic numbers in the log trace-context injection with named constexpr constants (kTraceIdPrefix, kSpanIdPrefix, kTraceIdHexLen, kSpanIdHexLen), documenting that the widths are the W3C 16-byte trace_id / 8-byte span_id rendered as lowercase hex. No behavior change. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/libxrpl/basics/Log.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/libxrpl/basics/Log.cpp b/src/libxrpl/basics/Log.cpp index 7111bc5f34..46a3829e78 100644 --- a/src/libxrpl/basics/Log.cpp +++ b/src/libxrpl/basics/Log.cpp @@ -17,6 +17,7 @@ #endif // XRPL_ENABLE_TELEMETRY #include +#include #include #include #include @@ -315,13 +316,21 @@ Logs::format( auto spanCtx = span->GetContext(); if (spanCtx.IsValid()) { - char traceId[32], spanId[16]; - spanCtx.trace_id().ToLowerBase16(opentelemetry::nostd::span{traceId}); - spanCtx.span_id().ToLowerBase16(opentelemetry::nostd::span{spanId}); - output += "trace_id="; - output.append(traceId, 32); - output += " span_id="; - output.append(spanId, 16); + // Hex widths of a W3C trace context: 16-byte trace_id and + // 8-byte span_id render to 32 and 16 lowercase hex chars. + constexpr std::size_t kTraceIdHexLen = 32; + constexpr std::size_t kSpanIdHexLen = 16; + constexpr auto kTraceIdPrefix = "trace_id="; + constexpr auto kSpanIdPrefix = " span_id="; + char traceId[kTraceIdHexLen], spanId[kSpanIdHexLen]; + spanCtx.trace_id().ToLowerBase16( + opentelemetry::nostd::span{traceId}); + spanCtx.span_id().ToLowerBase16( + opentelemetry::nostd::span{spanId}); + output += kTraceIdPrefix; + output.append(traceId, kTraceIdHexLen); + output += kSpanIdPrefix; + output.append(spanId, kSpanIdHexLen); output += ' '; } } From 3b4ef04575bd5e243e385621b64a837b6b0aa636 Mon Sep 17 00:00:00 2001 From: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> Date: Fri, 24 Jul 2026 15:33:07 +0100 Subject: [PATCH 2/2] ci(codecov): ignore per-module *SpanNames.h headers in coverage The colocated span-name headers (RpcSpanNames.h, ConsensusSpanNames.h, PeerSpanNames.h, etc.) hold only compile-time constant strings and live next to their subsystem rather than under a telemetry/ directory, so the existing dir-prefix ignores miss them. Add a **/*SpanNames.h glob so they do not count against patch coverage; like the rest of the telemetry surface they are not exercised in the coverage build. Co-Authored-By: Claude Opus 4.8 (1M context) --- .codecov.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.codecov.yml b/.codecov.yml index 303632a7f1..84722f5810 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -41,3 +41,6 @@ ignore: - "src/xrpld/telemetry/" - "src/libxrpl/telemetry/" - "include/xrpl/telemetry/" + # Per-module span-name constant headers (compile-time constants only, + # colocated with their subsystem rather than under telemetry/). + - "**/*SpanNames.h"