diff --git a/service/OneService.cpp b/service/OneService.cpp index 6bf867c36..8dc87d012 100644 --- a/service/OneService.cpp +++ b/service/OneService.cpp @@ -1074,16 +1074,19 @@ class OneServiceImpl : public OneService { auto processor = std::unique_ptr(new sdktrace::BatchSpanProcessor(std::move(exporter), batch_options)); auto processors = std::vector >(); processors.push_back(std::move(processor)); + char buf[256]; auto versionString = std::stringstream(); versionString << ZEROTIER_ONE_VERSION_MAJOR << "." << ZEROTIER_ONE_VERSION_MINOR << "." << ZEROTIER_ONE_VERSION_REVISION; auto resource_attributes = sdkresource::ResourceAttributes { { "service.version", versionString.str() }, { "service.node_id", _node->identity().address().toString(buf) }, { "service.namespace", "com.zerotier.zerotier-one" } }; auto resource = sdkresource::Resource::Create(resource_attributes); - auto recvd_attributes = resource.GetAttributes(); - if (! recvd_attributes.contains("service.name")) { + auto recvd_attributes = resource.GetAttributes().GetAttributes(); + // If service.name is not set, we set it to "zerotier-one" + if (recvd_attributes.find("service.name") != recvd_attributes.end()) { resource_attributes["service.name"] = "zerotier-one"; resource = sdkresource::Resource::Create(resource_attributes); } + auto sampler = std::unique_ptr(new sdktrace::TraceIdRatioBasedSampler(_exporterSampleRate)); auto tracer_context = std::make_unique(std::move(processors), resource, std::move(sampler)); _traceProvider = opentelemetry::nostd::shared_ptr(new sdktrace::TracerProvider(std::move(tracer_context)));