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 %} 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 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 diff --git a/src/libxrpl/telemetry/SpanGuard.cpp b/src/libxrpl/telemetry/SpanGuard.cpp index 41a5c9d380..6a5b1fb5a0 100644 --- a/src/libxrpl/telemetry/SpanGuard.cpp +++ b/src/libxrpl/telemetry/SpanGuard.cpp @@ -48,9 +48,11 @@ #include #include #include +#include #include #include #include +#include namespace xrpl::telemetry { @@ -463,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());