From a8d70c15f8e9b1639b3ad064f113c7a7b8ed11b1 Mon Sep 17 00:00:00 2001 From: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> Date: Mon, 1 Jun 2026 15:08:10 +0100 Subject: [PATCH 01/11] clang-tidy issue Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> --- src/libxrpl/telemetry/SpanGuard.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libxrpl/telemetry/SpanGuard.cpp b/src/libxrpl/telemetry/SpanGuard.cpp index c504b9f905..dc344ec923 100644 --- a/src/libxrpl/telemetry/SpanGuard.cpp +++ b/src/libxrpl/telemetry/SpanGuard.cpp @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include From 781e08a6a6c2202b3e10c4b5f17bbda53bebf7ec Mon Sep 17 00:00:00 2001 From: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> Date: Mon, 1 Jun 2026 15:28:12 +0100 Subject: [PATCH 02/11] force static build of otel protobuf on windows Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> --- conan/profiles/default | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/conan/profiles/default b/conan/profiles/default index cde59f7f3b..fd977f3dcc 100644 --- a/conan/profiles/default +++ b/conan/profiles/default @@ -23,3 +23,15 @@ compiler.libcxx={{detect_api.detect_libcxx(compiler, version, compiler_exe)}} {% if compiler == "gcc" and compiler_version < 13 %} tools.build:cxxflags+=['-Wno-restrict'] {% endif %} +{% if os == "Windows" %} +# opentelemetry-cpp's recipe removes the `shared` option on Windows and never +# sets BUILD_SHARED_LIBS, so its upstream CMake defaults the protobuf-generated +# `opentelemetry_proto` target to a DLL (opentelemetry_proto.dll). The rest of +# the project links statically and nothing deploys that DLL next to the +# executables, so the telemetry unit test fails to start with +# STATUS_DLL_NOT_FOUND (0xC0000135). Force the dependency to build fully static +# so no runtime DLL is produced. The conf is folded into the package id so a +# fresh static binary is built instead of reusing a previously cached one. +opentelemetry-cpp/*:tools.cmake.cmaketoolchain:extra_variables={"BUILD_SHARED_LIBS": "OFF"} +opentelemetry-cpp/*:tools.info.package_id:confs+=["tools.cmake.cmaketoolchain:extra_variables"] +{% endif %} From 34a2afa704bb190bb4da855e501a5d83ddcd0d54 Mon Sep 17 00:00:00 2001 From: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> Date: Mon, 1 Jun 2026 15:42:59 +0100 Subject: [PATCH 03/11] clang-tidy issue fix Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> --- src/libxrpl/telemetry/SpanGuard.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libxrpl/telemetry/SpanGuard.cpp b/src/libxrpl/telemetry/SpanGuard.cpp index dc344ec923..358132fec8 100644 --- a/src/libxrpl/telemetry/SpanGuard.cpp +++ b/src/libxrpl/telemetry/SpanGuard.cpp @@ -52,6 +52,7 @@ #include #include #include +#include namespace xrpl::telemetry { From eeae09c645cb266ca8a6de365146c4f1722d6007 Mon Sep 17 00:00:00 2001 From: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> Date: Mon, 1 Jun 2026 15:53:30 +0100 Subject: [PATCH 04/11] build issues Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> --- src/libxrpl/beast/insight/OTelCollector.cpp | 31 ++++++++++----------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/libxrpl/beast/insight/OTelCollector.cpp b/src/libxrpl/beast/insight/OTelCollector.cpp index 555c9ed207..098d39d2d4 100644 --- a/src/libxrpl/beast/insight/OTelCollector.cpp +++ b/src/libxrpl/beast/insight/OTelCollector.cpp @@ -54,7 +54,7 @@ #include #include #include -#include +#include #include #include @@ -362,7 +362,7 @@ private: * @code * auto collector = OTelCollector::New( * "http://localhost:4318/v1/metrics", "xrpld", journal); - * auto counter = collector->make_counter("rpc.requests"); + * auto counter = collector->makeCounter("rpc.requests"); * counter.increment(1); * // Metric "xrpld_rpc_requests" exported via OTLP every 1s. * @endcode @@ -393,19 +393,19 @@ public: /** @name Collector interface implementation */ /** @{ */ Hook - make_hook(HookImpl::HandlerType const& handler) override; + makeHook(HookImpl::HandlerType const& handler) override; Counter - make_counter(std::string const& name) override; + makeCounter(std::string const& name) override; Event - make_event(std::string const& name) override; + makeEvent(std::string const& name) override; Gauge - make_gauge(std::string const& name) override; + makeGauge(std::string const& name) override; Meter - make_meter(std::string const& name) override; + makeMeter(std::string const& name) override; /** @} */ /** @name Hook management for observable callbacks */ @@ -680,9 +680,9 @@ OTelCollectorImp::OTelCollectorImp( // Include service.instance.id when provided so Prometheus // exported_instance labels distinguish multi-node deployments. resource::ResourceAttributes attrs; - attrs[resource::SemanticConventions::kServiceName] = "xrpld"; + attrs[opentelemetry::semconv::service::kServiceName] = "xrpld"; if (!instanceId.empty()) - attrs[resource::SemanticConventions::kServiceInstanceId] = instanceId; + attrs[opentelemetry::semconv::service::kServiceInstanceId] = instanceId; auto resourceAttrs = resource::Resource::Create(attrs); // Create MeterProvider with resource, then attach the metric reader. @@ -701,7 +701,6 @@ OTelCollectorImp::OTelCollectorImp( auto histogramView = metrics_sdk::ViewFactory::Create( "default_histogram", "Default histogram view with SpanMetrics-compatible buckets", - "ms", metrics_sdk::AggregationType::kHistogram, std::move(histogramConfig)); @@ -729,32 +728,32 @@ OTelCollectorImp::~OTelCollectorImp() } Hook -OTelCollectorImp::make_hook(HookImpl::HandlerType const& handler) +OTelCollectorImp::makeHook(HookImpl::HandlerType const& handler) { return Hook(std::make_shared(handler, shared_from_this())); } Counter -OTelCollectorImp::make_counter(std::string const& name) +OTelCollectorImp::makeCounter(std::string const& name) { return Counter(std::make_shared(formatName(name), m_otelMeter)); } Event -OTelCollectorImp::make_event(std::string const& name) +OTelCollectorImp::makeEvent(std::string const& name) { return Event(std::make_shared(formatName(name), m_otelMeter)); } Gauge -OTelCollectorImp::make_gauge(std::string const& name) +OTelCollectorImp::makeGauge(std::string const& name) { return Gauge( std::make_shared(formatName(name), m_otelMeter, shared_from_this())); } Meter -OTelCollectorImp::make_meter(std::string const& name) +OTelCollectorImp::makeMeter(std::string const& name) { return Meter(std::make_shared(formatName(name), m_otelMeter)); } @@ -871,7 +870,7 @@ OTelCollector::New( std::string const& /* instanceId */, Journal /* journal */) { - return NullCollector::New(); + return NullCollector::make(); } } // namespace beast::insight From 967f0082c32f54613d3735424e52c8425b6c7730 Mon Sep 17 00:00:00 2001 From: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> Date: Mon, 1 Jun 2026 15:59:16 +0100 Subject: [PATCH 05/11] minor compilation issue introduced by merge Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> --- src/xrpld/telemetry/TxTracing.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/xrpld/telemetry/TxTracing.h b/src/xrpld/telemetry/TxTracing.h index 68b4903f88..fe47d4f068 100644 --- a/src/xrpld/telemetry/TxTracing.h +++ b/src/xrpld/telemetry/TxTracing.h @@ -36,7 +36,7 @@ txReceiveSpan(uint256 const& txID, [[maybe_unused]] protocol::TMTransaction cons TraceCategory::Transactions, tx_span::receive, txID.data(), - txID.bytes, + txID.kBytes, reinterpret_cast(tc.span_id().data()), tc.span_id().size(), tc.has_trace_flags() ? static_cast(tc.trace_flags()) @@ -45,7 +45,7 @@ txReceiveSpan(uint256 const& txID, [[maybe_unused]] protocol::TMTransaction cons } #endif return SpanGuard::hashSpan( - TraceCategory::Transactions, tx_span::receive, txID.data(), txID.bytes); + TraceCategory::Transactions, tx_span::receive, txID.data(), txID.kBytes); } /** Create a "tx.process" span for transaction processing in NetworkOPs. @@ -55,7 +55,7 @@ inline SpanGuard txProcessSpan(uint256 const& txID) { return SpanGuard::hashSpan( - TraceCategory::Transactions, tx_span::process, txID.data(), txID.bytes); + TraceCategory::Transactions, tx_span::process, txID.data(), txID.kBytes); } } // namespace xrpl::telemetry From 20a6274a48ffcaef367f5eba9dd4564b9fd12ad8 Mon Sep 17 00:00:00 2001 From: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> Date: Mon, 1 Jun 2026 16:07:58 +0100 Subject: [PATCH 06/11] minor namespace fix Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> --- src/libxrpl/telemetry/SpanGuard.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libxrpl/telemetry/SpanGuard.cpp b/src/libxrpl/telemetry/SpanGuard.cpp index c0330192da..6a5b1fb5a0 100644 --- a/src/libxrpl/telemetry/SpanGuard.cpp +++ b/src/libxrpl/telemetry/SpanGuard.cpp @@ -465,9 +465,7 @@ SpanGuard::addEvent(std::string_view name, std::initializer_list // OTel's AddEvent template requires a key-value-iterable; a plain // std::vector> doesn't satisfy is_key_value_iterable. // Wrap in nostd::span over the vector's storage so the SDK accepts it. - std::vector> + std::vector> otelAttrs; otelAttrs.reserve(attrs.size()); From 47f3480fb993ca39cc7b31ad8555d7b5eb730273 Mon Sep 17 00:00:00 2001 From: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> Date: Mon, 1 Jun 2026 16:11:14 +0100 Subject: [PATCH 07/11] fix(telemetry): replace indirect OTel includes with direct headers in Log.cpp clang-tidy misc-include-cleaner requires each symbol to be provided by a directly-included header. Replace the convenience trace/context.h (which only provides GetSpan/SetSpan) with the specific headers for kSpanKey, holds_alternative, get, shared_ptr, Span, and span. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/libxrpl/basics/Log.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libxrpl/basics/Log.cpp b/src/libxrpl/basics/Log.cpp index a841dcd910..c560b8bbd0 100644 --- a/src/libxrpl/basics/Log.cpp +++ b/src/libxrpl/basics/Log.cpp @@ -9,7 +9,11 @@ #ifdef XRPL_ENABLE_TELEMETRY #include -#include +#include +#include +#include +#include +#include #endif // XRPL_ENABLE_TELEMETRY #include From 124e3a154de54a369722356e7708149e8397c6e7 Mon Sep 17 00:00:00 2001 From: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> Date: Mon, 1 Jun 2026 16:32:43 +0100 Subject: [PATCH 08/11] fix(tests): add getMetricsRegistry() override to TestServiceRegistry ServiceRegistry gained the pure virtual getMetricsRegistry() in phase 7 but TestServiceRegistry was never updated. Returns nullptr since tests don't need a real MetricsRegistry. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/tests/libxrpl/helpers/TestServiceRegistry.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/tests/libxrpl/helpers/TestServiceRegistry.h b/src/tests/libxrpl/helpers/TestServiceRegistry.h index c159bd9c1f..774161d9d0 100644 --- a/src/tests/libxrpl/helpers/TestServiceRegistry.h +++ b/src/tests/libxrpl/helpers/TestServiceRegistry.h @@ -334,6 +334,12 @@ public: throw std::logic_error("TestServiceRegistry::getTelemetry() not implemented"); } + telemetry::MetricsRegistry* + getMetricsRegistry() override + { + return nullptr; + } + // Configuration and state bool isStopping() const override From 2ac93c504e3dba5b29304ab226a91021a2fa4e8e Mon Sep 17 00:00:00 2001 From: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> Date: Mon, 1 Jun 2026 16:45:38 +0100 Subject: [PATCH 09/11] fix(tests): rename make_Telemetry to telemetry::makeTelemetry in Peer.h The project-wide rename check changed the factory function name but missed this call site in the consensus simulation test framework. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/test/csf/Peer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/csf/Peer.h b/src/test/csf/Peer.h index 6fa114fb34..74406b9c83 100644 --- a/src/test/csf/Peer.h +++ b/src/test/csf/Peer.h @@ -645,7 +645,7 @@ struct Peer telemetry::Telemetry& getTelemetry() { - static auto tel = make_Telemetry( + static auto tel = telemetry::makeTelemetry( telemetry::Telemetry::Setup{}, beast::Journal{beast::Journal::getNullSink()}); return *tel; } From dfdda305eec8bb8c8454a0aefab74aaa4e092113 Mon Sep 17 00:00:00 2001 From: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> Date: Mon, 1 Jun 2026 16:58:05 +0100 Subject: [PATCH 10/11] clang-tidy fixes Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> --- include/xrpl/beast/insight/OTelCollector.h | 1 + src/libxrpl/beast/insight/OTelCollector.cpp | 212 +++++++++++--------- 2 files changed, 114 insertions(+), 99 deletions(-) diff --git a/include/xrpl/beast/insight/OTelCollector.h b/include/xrpl/beast/insight/OTelCollector.h index ee4d294c0a..32a7fc621c 100644 --- a/include/xrpl/beast/insight/OTelCollector.h +++ b/include/xrpl/beast/insight/OTelCollector.h @@ -81,6 +81,7 @@ public: * @return Shared pointer to the created Collector. */ static std::shared_ptr + // NOLINTNEXTLINE(readability-identifier-naming) New(std::string const& endpoint, std::string const& prefix, std::string const& instanceId, diff --git a/src/libxrpl/beast/insight/OTelCollector.cpp b/src/libxrpl/beast/insight/OTelCollector.cpp index 098d39d2d4..c869451511 100644 --- a/src/libxrpl/beast/insight/OTelCollector.cpp +++ b/src/libxrpl/beast/insight/OTelCollector.cpp @@ -47,21 +47,30 @@ #include #include #include +#include +#include +#include +#include #include #include +#include #include #include #include #include #include +#include +#include #include +#include #include #include #include #include #include #include +#include #include namespace beast::insight { @@ -93,10 +102,13 @@ public: * @param handler Callback invoked at each collection interval. * @param impl Owning collector (prevents premature destruction). */ - OTelHookImpl(HandlerType const& handler, std::shared_ptr const& impl); + OTelHookImpl(HandlerType handler, std::shared_ptr impl); ~OTelHookImpl() override; + OTelHookImpl& + operator=(OTelHookImpl const&) = delete; + /** * @brief Invoke the stored handler. * @@ -107,14 +119,11 @@ public: callHandler(); private: - OTelHookImpl& - operator=(OTelHookImpl const&); - /** Owning collector. Prevents collector destruction while hook alive. */ - std::shared_ptr m_impl; + std::shared_ptr impl_; /** User-supplied handler called at each collection interval. */ - HandlerType m_handler; + HandlerType handler_; }; //------------------------------------------------------------------------------ @@ -141,6 +150,9 @@ public: ~OTelCounterImpl() override = default; + OTelCounterImpl& + operator=(OTelCounterImpl const&) = delete; + /** * @brief Add amount to the counter. * @param amount Value to add (must be non-negative for OTel counters). @@ -149,11 +161,8 @@ public: increment(value_type amount) override; private: - OTelCounterImpl& - operator=(OTelCounterImpl const&); - /** OTel synchronous counter instrument. */ - opentelemetry::nostd::unique_ptr> m_counter; + opentelemetry::nostd::unique_ptr> counter_; }; //------------------------------------------------------------------------------ @@ -181,6 +190,9 @@ public: ~OTelEventImpl() override = default; + OTelEventImpl& + operator=(OTelEventImpl const&) = delete; + /** * @brief Record a duration measurement. * @param value Duration in milliseconds. @@ -189,11 +201,8 @@ public: notify(value_type const& value) override; private: - OTelEventImpl& - operator=(OTelEventImpl const&); - /** OTel histogram instrument for recording durations. */ - opentelemetry::nostd::unique_ptr> m_histogram; + opentelemetry::nostd::unique_ptr> histogram_; }; //------------------------------------------------------------------------------ @@ -253,19 +262,19 @@ public: int64_t currentValue() const; + OTelGaugeImpl& + operator=(OTelGaugeImpl const&) = delete; + /** Static callback registered with the OTel SDK observable gauge. */ static void gaugeCallback(opentelemetry::metrics::ObserverResult result, void* state); private: - OTelGaugeImpl& - operator=(OTelGaugeImpl const&); - /** Current gauge value, updated atomically by set()/increment(). */ - std::atomic m_value{0}; + std::atomic value_{0}; /** OTel observable gauge handle (prevents deregistration). */ - opentelemetry::nostd::shared_ptr m_gauge; + opentelemetry::nostd::shared_ptr gauge_; /** Owning collector, used to invoke hooks before reading gauge values. */ std::shared_ptr collector_; @@ -299,6 +308,9 @@ public: ~OTelMeterImpl() override = default; + OTelMeterImpl& + operator=(OTelMeterImpl const&) = delete; + /** * @brief Add amount to the meter. * @param amount Value to add (unsigned). @@ -307,11 +319,8 @@ public: increment(value_type amount) override; private: - OTelMeterImpl& - operator=(OTelMeterImpl const&); - /** OTel synchronous counter instrument (unsigned). */ - opentelemetry::nostd::unique_ptr> m_counter; + opentelemetry::nostd::unique_ptr> counter_; }; //------------------------------------------------------------------------------ @@ -334,12 +343,12 @@ private: * +------------------+ | * | OTelCollectorImp |-------------+ * +------------------+ - * | - m_journal | - * | - m_prefix | - * | - m_provider | +---------------------+ - * | - m_otelMeter |---->| OTel MeterProvider | - * | - m_hooks[] | | + PeriodicReader | - * | - m_gauges[] | | + OtlpHttpExporter | + * | - journal_ | + * | - prefix_ | + * | - provider_ | +---------------------+ + * | - otelMeter_ |---->| OTel MeterProvider | + * | - hooks_[] | | + PeriodicReader | + * | - gauges_[] | | + OtlpHttpExporter | * +------------------+ +---------------------+ * * Lifecycle: @@ -381,7 +390,7 @@ public: */ OTelCollectorImp( std::string const& endpoint, - std::string const& prefix, + std::string prefix, std::string const& instanceId, Journal journal); @@ -475,25 +484,25 @@ public: private: /** Journal for log output. */ - Journal m_journal; + Journal journal_; /** Prefix for all metric names (e.g., "xrpld"). */ - std::string m_prefix; + std::string prefix_; /** OTel SDK MeterProvider owning the export pipeline. RAII lifecycle. */ - std::shared_ptr m_provider; + std::shared_ptr provider_; /** OTel Meter used to create all instruments. */ - opentelemetry::nostd::shared_ptr m_otelMeter; + opentelemetry::nostd::shared_ptr otelMeter_; /** Mutex protecting hook and gauge registration lists. */ - std::mutex m_mutex; + std::mutex mutex_; /** Registered hooks called during observable callbacks. */ - std::vector m_hooks; + std::vector hooks_; /** Registered gauges read during observable callbacks. */ - std::vector m_gauges; + std::vector gauges_; /** * @brief Debounce timestamp for callHooks(). @@ -503,7 +512,7 @@ private: * Hooks are called at most once per 500ms window to avoid redundant * invocations while still ensuring fresh values each collection cycle. */ - std::atomic m_lastHookCallMs{0}; + std::atomic lastHookCallMs_{0}; }; //============================================================================== @@ -514,23 +523,21 @@ private: // OTelHookImpl //------------------------------------------------------------------------------ -OTelHookImpl::OTelHookImpl( - HandlerType const& handler, - std::shared_ptr const& impl) - : m_impl(impl), m_handler(handler) +OTelHookImpl::OTelHookImpl(HandlerType handler, std::shared_ptr impl) + : impl_(std::move(impl)), handler_(std::move(handler)) { - m_impl->addHook(this); + impl_->addHook(this); } OTelHookImpl::~OTelHookImpl() { - m_impl->removeHook(this); + impl_->removeHook(this); } void OTelHookImpl::callHandler() { - m_handler(); + handler_(); } //------------------------------------------------------------------------------ @@ -540,7 +547,7 @@ OTelHookImpl::callHandler() OTelCounterImpl::OTelCounterImpl( std::string const& name, opentelemetry::nostd::shared_ptr const& meter) - : m_counter(meter->CreateUInt64Counter(name)) + : counter_(meter->CreateUInt64Counter(name)) { } @@ -550,7 +557,7 @@ OTelCounterImpl::increment(value_type amount) // OTel counters require non-negative values. beast::insight CounterImpl // uses int64_t, so clamp negative values to 0 and cast to uint64_t. if (amount > 0) - m_counter->Add(static_cast(amount)); + counter_->Add(static_cast(amount)); } //------------------------------------------------------------------------------ @@ -560,14 +567,14 @@ OTelCounterImpl::increment(value_type amount) OTelEventImpl::OTelEventImpl( std::string const& name, opentelemetry::nostd::shared_ptr const& meter) - : m_histogram(meter->CreateDoubleHistogram(name, "Duration in ms", "ms")) + : histogram_(meter->CreateDoubleHistogram(name, "Duration in ms", "ms")) { } void OTelEventImpl::notify(value_type const& value) { - m_histogram->Record(static_cast(value.count()), opentelemetry::context::Context{}); + histogram_->Record(static_cast(value.count()), opentelemetry::context::Context{}); } //------------------------------------------------------------------------------ @@ -578,10 +585,10 @@ OTelGaugeImpl::OTelGaugeImpl( std::string const& name, opentelemetry::nostd::shared_ptr const& meter, std::shared_ptr const& collector) - : m_gauge(meter->CreateInt64ObservableGauge(name)), collector_(collector) + : gauge_(meter->CreateInt64ObservableGauge(name)), collector_(collector) { collector_->addGauge(this); - m_gauge->AddCallback(gaugeCallback, this); + gauge_->AddCallback(gaugeCallback, this); } void @@ -599,35 +606,34 @@ OTelGaugeImpl::gaugeCallback(opentelemetry::metrics::ObserverResult result, void OTelGaugeImpl::~OTelGaugeImpl() { - m_gauge->RemoveCallback(gaugeCallback, this); + gauge_->RemoveCallback(gaugeCallback, this); collector_->removeGauge(this); } void OTelGaugeImpl::set(value_type value) { - m_value.store(static_cast(value), std::memory_order_relaxed); + value_.store(static_cast(value), std::memory_order_relaxed); } void OTelGaugeImpl::increment(difference_type amount) { // Use compare-exchange loop to safely clamp to [0, MAX]. - int64_t current = m_value.load(std::memory_order_relaxed); - int64_t desired; + int64_t current = value_.load(std::memory_order_relaxed); + int64_t desired = 0; do { desired = current + amount; // Clamp to 0 on underflow. - if (desired < 0) - desired = 0; - } while (!m_value.compare_exchange_weak(current, desired, std::memory_order_relaxed)); + desired = std::max(desired, int64_t{0}); + } while (!value_.compare_exchange_weak(current, desired, std::memory_order_relaxed)); } int64_t OTelGaugeImpl::currentValue() const { - return m_value.load(std::memory_order_relaxed); + return value_.load(std::memory_order_relaxed); } //------------------------------------------------------------------------------ @@ -637,14 +643,14 @@ OTelGaugeImpl::currentValue() const OTelMeterImpl::OTelMeterImpl( std::string const& name, opentelemetry::nostd::shared_ptr const& meter) - : m_counter(meter->CreateUInt64Counter(name)) + : counter_(meter->CreateUInt64Counter(name)) { } void OTelMeterImpl::increment(value_type amount) { - m_counter->Add(amount); + counter_->Add(amount); } //------------------------------------------------------------------------------ @@ -653,14 +659,15 @@ OTelMeterImpl::increment(value_type amount) OTelCollectorImp::OTelCollectorImp( std::string const& endpoint, - std::string const& prefix, + std::string prefix, std::string const& instanceId, Journal journal) - : m_journal(journal), m_prefix(prefix) + : journal_(journal), prefix_(std::move(prefix)) { - if (m_journal.info()) - m_journal.info() << "OTelCollector starting: endpoint=" << endpoint - << " prefix=" << m_prefix; + if (journal_.info()) + { + journal_.info() << "OTelCollector starting: endpoint=" << endpoint << " prefix=" << prefix_; + } // Configure OTLP HTTP metric exporter. otlp_http::OtlpHttpMetricExporterOptions exporterOpts; @@ -682,13 +689,15 @@ OTelCollectorImp::OTelCollectorImp( resource::ResourceAttributes attrs; attrs[opentelemetry::semconv::service::kServiceName] = "xrpld"; if (!instanceId.empty()) + { attrs[opentelemetry::semconv::service::kServiceInstanceId] = instanceId; + } auto resourceAttrs = resource::Resource::Create(attrs); // Create MeterProvider with resource, then attach the metric reader. - m_provider = metrics_sdk::MeterProviderFactory::Create( + provider_ = metrics_sdk::MeterProviderFactory::Create( std::make_unique(), resourceAttrs); - m_provider->AddMetricReader(std::move(reader)); + provider_->AddMetricReader(std::move(reader)); // Configure histogram bucket boundaries for Event instruments. // These match the SpanMetrics connector buckets for consistency. @@ -704,27 +713,33 @@ OTelCollectorImp::OTelCollectorImp( metrics_sdk::AggregationType::kHistogram, std::move(histogramConfig)); - m_provider->AddView( + provider_->AddView( std::move(histogramSelector), std::move(meterSelector), std::move(histogramView)); // Create the OTel Meter for creating instruments. - m_otelMeter = m_provider->GetMeter("xrpld_metrics", "1.0.0"); + otelMeter_ = provider_->GetMeter("xrpld_metrics", "1.0.0"); - if (m_journal.info()) - m_journal.info() << "OTelCollector started successfully"; + if (journal_.info()) + { + journal_.info() << "OTelCollector started successfully"; + } } OTelCollectorImp::~OTelCollectorImp() { - if (m_journal.info()) - m_journal.info() << "OTelCollector shutting down"; - if (m_provider) + if (journal_.info()) { - m_provider->ForceFlush(std::chrono::milliseconds(2000)); - m_provider->Shutdown(); + journal_.info() << "OTelCollector shutting down"; + } + if (provider_) + { + provider_->ForceFlush(std::chrono::milliseconds(2000)); + provider_->Shutdown(); + } + if (journal_.info()) + { + journal_.info() << "OTelCollector stopped"; } - if (m_journal.info()) - m_journal.info() << "OTelCollector stopped"; } Hook @@ -736,40 +751,39 @@ OTelCollectorImp::makeHook(HookImpl::HandlerType const& handler) Counter OTelCollectorImp::makeCounter(std::string const& name) { - return Counter(std::make_shared(formatName(name), m_otelMeter)); + return Counter(std::make_shared(formatName(name), otelMeter_)); } Event OTelCollectorImp::makeEvent(std::string const& name) { - return Event(std::make_shared(formatName(name), m_otelMeter)); + return Event(std::make_shared(formatName(name), otelMeter_)); } Gauge OTelCollectorImp::makeGauge(std::string const& name) { - return Gauge( - std::make_shared(formatName(name), m_otelMeter, shared_from_this())); + return Gauge(std::make_shared(formatName(name), otelMeter_, shared_from_this())); } Meter OTelCollectorImp::makeMeter(std::string const& name) { - return Meter(std::make_shared(formatName(name), m_otelMeter)); + return Meter(std::make_shared(formatName(name), otelMeter_)); } void OTelCollectorImp::addHook(OTelHookImpl* hook) { - std::lock_guard lock(m_mutex); - m_hooks.push_back(hook); + std::lock_guard lock(mutex_); + hooks_.push_back(hook); } void OTelCollectorImp::removeHook(OTelHookImpl* hook) { - std::lock_guard lock(m_mutex); - m_hooks.erase(std::remove(m_hooks.begin(), m_hooks.end(), hook), m_hooks.end()); + std::lock_guard lock(mutex_); + hooks_.erase(std::remove(hooks_.begin(), hooks_.end(), hook), hooks_.end()); } void @@ -782,35 +796,35 @@ OTelCollectorImp::callHooks() auto now = std::chrono::duration_cast( std::chrono::steady_clock::now().time_since_epoch()) .count(); - auto last = m_lastHookCallMs.load(std::memory_order_acquire); + auto last = lastHookCallMs_.load(std::memory_order_acquire); if (now - last < 500) return; - if (!m_lastHookCallMs.compare_exchange_strong(last, now, std::memory_order_acq_rel)) + if (!lastHookCallMs_.compare_exchange_strong(last, now, std::memory_order_acq_rel)) return; // Another thread won the race. - std::lock_guard lock(m_mutex); - for (auto* hook : m_hooks) + std::lock_guard lock(mutex_); + for (auto* hook : hooks_) hook->callHandler(); } void OTelCollectorImp::addGauge(OTelGaugeImpl* gauge) { - std::lock_guard lock(m_mutex); - m_gauges.push_back(gauge); + std::lock_guard lock(mutex_); + gauges_.push_back(gauge); } void OTelCollectorImp::removeGauge(OTelGaugeImpl* gauge) { - std::lock_guard lock(m_mutex); - m_gauges.erase(std::remove(m_gauges.begin(), m_gauges.end(), gauge), m_gauges.end()); + std::lock_guard lock(mutex_); + gauges_.erase(std::remove(gauges_.begin(), gauges_.end(), gauge), gauges_.end()); } opentelemetry::nostd::shared_ptr const& OTelCollectorImp::otelMeter() const { - return m_otelMeter; + return otelMeter_; } std::string @@ -823,9 +837,9 @@ OTelCollectorImp::formatName(std::string const& name) const // Example: prefix="xrpld", name="LedgerMaster.Validated_Ledger_Age" // -> "xrpld_LedgerMaster_Validated_Ledger_Age" std::string result; - if (!m_prefix.empty()) + if (!prefix_.empty()) { - result = m_prefix; + result = prefix_; result += '_'; } for (char c : name) From 615d339f84914b26a2da3c9a886c47b54968db27 Mon Sep 17 00:00:00 2001 From: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> Date: Mon, 1 Jun 2026 17:03:27 +0100 Subject: [PATCH 11/11] =?UTF-8?q?fix(docs):=20apply=20rename=20scripts=20?= =?UTF-8?q?=E2=80=94=20prefix=3Drippled=20to=20prefix=3Dxrpld?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The check-rename CI job requires all rename scripts to have been run. The telemetry config files had 'prefix=rippled' which should be 'xrpld'. Co-Authored-By: Claude Opus 4.6 (1M context) --- docker/telemetry/xrpld-telemetry-mainnet.cfg | 2 +- docker/telemetry/xrpld-telemetry.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/telemetry/xrpld-telemetry-mainnet.cfg b/docker/telemetry/xrpld-telemetry-mainnet.cfg index e57bbfef60..57ddaff146 100644 --- a/docker/telemetry/xrpld-telemetry-mainnet.cfg +++ b/docker/telemetry/xrpld-telemetry-mainnet.cfg @@ -110,7 +110,7 @@ docker/telemetry/data [insight] server=otel endpoint=http://localhost:4318/v1/metrics -prefix=rippled +prefix=xrpld # --- OpenTelemetry tracing -------------------------------------------------- diff --git a/docker/telemetry/xrpld-telemetry.cfg b/docker/telemetry/xrpld-telemetry.cfg index 05764d32c0..453fe50439 100644 --- a/docker/telemetry/xrpld-telemetry.cfg +++ b/docker/telemetry/xrpld-telemetry.cfg @@ -108,7 +108,7 @@ docker/telemetry/data [insight] server=otel endpoint=http://localhost:4318/v1/metrics -prefix=rippled +prefix=xrpld # --- OpenTelemetry tracing --------------------------------------------------