From 4cbb1be5b419857bb427aaa97c14fddd9765caf2 Mon Sep 17 00:00:00 2001 From: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> Date: Wed, 13 May 2026 14:11:16 +0100 Subject: [PATCH] =?UTF-8?q?fix(telemetry):=20CI=20Werror=20=E2=80=94=20reg?= =?UTF-8?q?istry=20.get()=20and=20unused=20fields?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two build failures surfaced by CI on the Phase 9 branch: 1. NetworkOPsImp stores the ServiceRegistry as std::reference_wrapper registry_, so calls must go through registry_.get().(). The MetricsRegistry hooks added in setMode() and recvValidation() dereferenced the wrapper directly, which compiles against a pre-existing accessor on the wrapper type on some toolchains but fails on clang 16/17/20 and gcc 13/15 with "no member named 'getMetricsRegistry' in std::reference_wrapper". 2. MetricsRegistry::app_ and MetricsRegistry::journal_ are only used inside XRPL_ENABLE_TELEMETRY-guarded code paths (gauge callbacks and JLOG). When telemetry is disabled, clang's -Werror=-Wunused-private-field tripped. Move the two fields under the same #ifdef and guard the constructor initialisers with [[maybe_unused]] so the no-op build continues to compile cleanly. --- src/xrpld/app/misc/NetworkOPs.cpp | 4 ++-- src/xrpld/telemetry/MetricsRegistry.cpp | 11 +++++++++-- src/xrpld/telemetry/MetricsRegistry.h | 13 +++++++------ 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/xrpld/app/misc/NetworkOPs.cpp b/src/xrpld/app/misc/NetworkOPs.cpp index 10cdc5f414..9e93b8fe51 100644 --- a/src/xrpld/app/misc/NetworkOPs.cpp +++ b/src/xrpld/app/misc/NetworkOPs.cpp @@ -2536,7 +2536,7 @@ NetworkOPsImp::setMode(OperatingMode om) accounting_.mode(om); // Record state change for OTel dashboard parity counter. - if (auto* mr = registry_.getMetricsRegistry()) + if (auto* mr = registry_.get().getMetricsRegistry()) mr->incrementStateChanges(); JLOG(m_journal.info()) << "STATE->" << strOperatingMode(); @@ -2547,7 +2547,7 @@ bool NetworkOPsImp::recvValidation(std::shared_ptr const& val, std::string const& source) { JLOG(m_journal.trace()) << "recvValidation " << val->getLedgerHash() << " from " << source; - if (auto* mr = registry_.getMetricsRegistry()) + if (auto* mr = registry_.get().getMetricsRegistry()) mr->incrementValidationsChecked(); std::unique_lock lock(validationsMutex_); diff --git a/src/xrpld/telemetry/MetricsRegistry.cpp b/src/xrpld/telemetry/MetricsRegistry.cpp index 73ada76032..863e9bfa46 100644 --- a/src/xrpld/telemetry/MetricsRegistry.cpp +++ b/src/xrpld/telemetry/MetricsRegistry.cpp @@ -65,8 +65,15 @@ namespace resource = opentelemetry::sdk::resource; namespace xrpl { namespace telemetry { -MetricsRegistry::MetricsRegistry(bool enabled, ServiceRegistry& app, beast::Journal journal) - : enabled_(enabled), app_(app), journal_(journal) +MetricsRegistry::MetricsRegistry( + [[maybe_unused]] bool enabled, + [[maybe_unused]] ServiceRegistry& app, + [[maybe_unused]] beast::Journal journal) + : enabled_(enabled) +#ifdef XRPL_ENABLE_TELEMETRY + , app_(app) + , journal_(journal) +#endif { } diff --git a/src/xrpld/telemetry/MetricsRegistry.h b/src/xrpld/telemetry/MetricsRegistry.h index 317fa426f1..4d2cf11d1b 100644 --- a/src/xrpld/telemetry/MetricsRegistry.h +++ b/src/xrpld/telemetry/MetricsRegistry.h @@ -340,12 +340,6 @@ private: /// Master enable flag; when false all methods are no-ops. bool const enabled_; - /// Reference to Application services for gauge callbacks. - ServiceRegistry& app_; - - /// Journal for logging. - beast::Journal const journal_; - /// Tracks validation agreement between this node and the network. /// Lives outside the XRPL_ENABLE_TELEMETRY guard because it is /// always safe to record events; the gauge callback simply won't @@ -353,6 +347,13 @@ private: ValidationTracker validationTracker_; #ifdef XRPL_ENABLE_TELEMETRY + /// Reference to Application services for gauge callbacks. + /// Only needed when OTel is compiled in, since observable gauge + /// callbacks live entirely inside the XRPL_ENABLE_TELEMETRY guard. + ServiceRegistry& app_; + + /// Journal for logging. + beast::Journal const journal_; /// The SDK MeterProvider that owns the export pipeline. std::shared_ptr provider_;