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.
This commit is contained in:
Pratik Mankawde
2026-09-17 13:44:53 +01:00
parent ec0bfe521d
commit 327b5bb229
3 changed files with 11 additions and 2 deletions

View File

@@ -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

View File

@@ -39,7 +39,7 @@
#include <xrpl/resource/Consumer.h>
#include <xrpl/server/InfoSub.h>
#include <xrpl/server/LoadFeeTrack.h>
#include <xrpl/telemetry/MetricMacros.h>
#include <xrpl/telemetry/MetricMacros.h> // IWYU pragma: keep
#include <xrpl/telemetry/Redaction.h>
#include <xrpl/telemetry/SpanGuard.h>
#include <xrpl/tx/paths/RippleCalc.h>

View File

@@ -24,6 +24,11 @@
#include <xrpld/telemetry/AppMetricGauges.h>
// Both name types in the constructor signature, which is compiled in either
// way, so they belong outside the telemetry guard below.
#include <xrpl/beast/utility/Journal.h>
#include <xrpl/telemetry/MetricsRegistry.h>
#ifdef XRPL_ENABLE_TELEMETRY
// The app and overlay includes below are why
@@ -56,7 +61,6 @@
#include <xrpl/basics/CountedObject.h>
#include <xrpl/basics/Log.h>
#include <xrpl/basics/UptimeClock.h>
#include <xrpl/beast/utility/Journal.h>
#include <xrpl/core/ServiceRegistry.h>
#include <xrpl/json/json_value.h>
#include <xrpl/nodestore/Database.h>