From 327b5bb229334c307341b53dc9cdcfd280d0c95f Mon Sep 17 00:00:00 2001 From: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> Date: Thu, 17 Sep 2026 13:44:53 +0100 Subject: [PATCH 1/2] fix(telemetry): keep the telemetry-off build clean A -DXRPL_ENABLE_TELEMETRY=0 build expands every XRPL_METRIC_* macro to nothing, so anything whose only use sits inside one looks unused. - MetricsRegistry::hasPipeline touches no member in that build, so clang-tidy asks for it to be static. Making it static would give the two builds different signatures, so suppress it the way Recording.h already does for the same reason. - PathRequest.cpp's only use of MetricMacros.h is such a macro, so mark the include as kept. - AppMetricGauges.cpp names MetricsRegistry and beast::Journal in a constructor signature that is compiled either way, so their includes move outside the telemetry guard. --- src/libxrpl/telemetry/MetricsRegistry.cpp | 5 +++++ src/xrpld/rpc/detail/PathRequest.cpp | 2 +- src/xrpld/telemetry/AppMetricGauges.cpp | 6 +++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/libxrpl/telemetry/MetricsRegistry.cpp b/src/libxrpl/telemetry/MetricsRegistry.cpp index 177cedf8b0..43a75563f4 100644 --- a/src/libxrpl/telemetry/MetricsRegistry.cpp +++ b/src/libxrpl/telemetry/MetricsRegistry.cpp @@ -404,6 +404,10 @@ MetricsRegistry::stop() #endif // XRPL_ENABLE_TELEMETRY } +// This reads provider_ when telemetry is compiled in and touches no member +// when it is not, so clang-tidy asks for it to be static. Making it static +// would give the two builds different signatures. +// NOLINTBEGIN(readability-convert-member-functions-to-static) bool MetricsRegistry::hasPipeline() const noexcept { @@ -413,6 +417,7 @@ MetricsRegistry::hasPipeline() const noexcept return false; #endif } +// NOLINTEND(readability-convert-member-functions-to-static) // ----------------------------------------------------------------- // Synchronous instrument recording — RPC metrics diff --git a/src/xrpld/rpc/detail/PathRequest.cpp b/src/xrpld/rpc/detail/PathRequest.cpp index c891111978..888546ad0a 100644 --- a/src/xrpld/rpc/detail/PathRequest.cpp +++ b/src/xrpld/rpc/detail/PathRequest.cpp @@ -39,7 +39,7 @@ #include #include #include -#include +#include // IWYU pragma: keep #include #include #include diff --git a/src/xrpld/telemetry/AppMetricGauges.cpp b/src/xrpld/telemetry/AppMetricGauges.cpp index 655bb7195f..af0e7a1ce4 100644 --- a/src/xrpld/telemetry/AppMetricGauges.cpp +++ b/src/xrpld/telemetry/AppMetricGauges.cpp @@ -24,6 +24,11 @@ #include +// Both name types in the constructor signature, which is compiled in either +// way, so they belong outside the telemetry guard below. +#include +#include + #ifdef XRPL_ENABLE_TELEMETRY // The app and overlay includes below are why @@ -56,7 +61,6 @@ #include #include #include -#include #include #include #include From 06b7087c9fea02e9be807648da15e5a3aa6077b1 Mon Sep 17 00:00:00 2001 From: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> Date: Thu, 17 Sep 2026 13:45:06 +0100 Subject: [PATCH 2/2] fix(nodestore): keep the rotation-phase code building with telemetry off RotationPhase reads owner_ and stage_ only inside the metric macro in its destructor. With -DXRPL_ENABLE_TELEMETRY=0 that macro expands to nothing, so clang reports both as unused private fields and -Werror makes it an error. Mark them [[maybe_unused]]. The rotation-phase label constants reach RotationPhase as ordinary constructor arguments, not as macro arguments, so MetricNames.h is needed in both builds and no longer sits under the telemetry guard. --- src/xrpld/app/misc/SHAMapStoreImp.cpp | 8 +++----- src/xrpld/app/misc/SHAMapStoreImp.h | 6 ++++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/xrpld/app/misc/SHAMapStoreImp.cpp b/src/xrpld/app/misc/SHAMapStoreImp.cpp index 6f454a1f04..f1557fec79 100644 --- a/src/xrpld/app/misc/SHAMapStoreImp.cpp +++ b/src/xrpld/app/misc/SHAMapStoreImp.cpp @@ -29,12 +29,10 @@ #include #include #include -#include -#ifdef XRPL_ENABLE_TELEMETRY -// The metric-name constants are named only as macro arguments, which the -// macros drop when telemetry is compiled out. +// MetricNames.h is unguarded because the rotation-phase label constants are +// passed to RotationPhase as ordinary constructor arguments, in both builds. +#include // IWYU pragma: keep #include -#endif #include #include diff --git a/src/xrpld/app/misc/SHAMapStoreImp.h b/src/xrpld/app/misc/SHAMapStoreImp.h index 5d03b26ce6..07e6685962 100644 --- a/src/xrpld/app/misc/SHAMapStoreImp.h +++ b/src/xrpld/app/misc/SHAMapStoreImp.h @@ -253,8 +253,10 @@ private: } private: - SHAMapStoreImp& owner_; - char const* stage_; + // Read only inside the metric macro in the destructor, so a + // -DXRPL_ENABLE_TELEMETRY=0 build sees no use at all. + [[maybe_unused]] SHAMapStoreImp& owner_; + [[maybe_unused]] char const* stage_; std::chrono::steady_clock::time_point start_ = std::chrono::steady_clock::now(); telemetry::ScopedSpanGuard span_; };