From 761c4e2872f36d7dca272223bd0c0958cdf197ab Mon Sep 17 00:00:00 2001 From: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> Date: Thu, 6 Aug 2026 11:56:21 +0100 Subject: [PATCH] fix(telemetry): rename OTel resource alias to avoid xrpl::resource clash develop renamed xrpl::Resource to xrpl::resource. MetricsRegistry.cpp declared `namespace resource = opentelemetry::sdk::resource` at file scope, but both use sites are inside namespace xrpl::telemetry, where inner-scope lookup finds the enclosing xrpl::resource first and never reaches the alias. That namespace has no ResourceAttributes or Resource, so the build failed on all four platforms: error: no type named 'ResourceAttributes' in namespace 'xrpl::resource' error: no member named 'Create' in namespace 'xrpl::resource'; did you mean 'creat'? Rename the alias to otel_resource. Moving it inside xrpl::telemetry would also compile, but only by shadowing xrpl::resource -- a reader at the use site still could not tell which namespace `resource::` meant, and a later using-directive would reintroduce the ambiguity. A distinct name removes the collision by construction and matches the metric_sdk / otlp_http aliases already in this file. --- src/xrpld/telemetry/MetricsRegistry.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/xrpld/telemetry/MetricsRegistry.cpp b/src/xrpld/telemetry/MetricsRegistry.cpp index 28c1e64dda..73af238945 100644 --- a/src/xrpld/telemetry/MetricsRegistry.cpp +++ b/src/xrpld/telemetry/MetricsRegistry.cpp @@ -80,7 +80,10 @@ namespace metric_sdk = opentelemetry::sdk::metrics; namespace otlp_http = opentelemetry::exporter::otlp; -namespace resource = opentelemetry::sdk::resource; +// Not `resource`: that would collide with xrpl::resource (the resource-accounting +// namespace), which encloses every use site below. Inner-scope lookup would find +// that namespace instead of this file-scope alias. +namespace otel_resource = opentelemetry::sdk::resource; namespace { @@ -290,7 +293,7 @@ MetricsRegistry::initExporterAndProvider(std::string const& endpoint, std::strin // Configure resource attributes so Prometheus service_instance_id labels // distinguish metrics from different nodes (matches OTelCollector setup). - resource::ResourceAttributes attrs; + otel_resource::ResourceAttributes attrs; // Use std::string, not a string literal: ResourceAttributes stores an // OTel AttributeValue variant whose char-const* overload binds to bool, // so "xrpld" would be recorded as the boolean true. std::string selects @@ -298,7 +301,7 @@ MetricsRegistry::initExporterAndProvider(std::string const& endpoint, std::strin attrs[opentelemetry::semconv::service::kServiceName] = std::string("xrpld"); if (!instanceId.empty()) attrs[opentelemetry::semconv::service::kServiceInstanceId] = instanceId; - auto resourceAttrs = resource::Resource::Create(attrs); + auto resourceAttrs = otel_resource::Resource::Create(attrs); // Build a view registry with explicit microsecond buckets for the // duration histograms. Without this they use the SDK default buckets