mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-08-02 15:02:50 +02:00
set service.name iff it's not set by the OTEL_SERVICE_NAME
env var
This commit is contained in:
parent
cf77a6a805
commit
a0cc7babdf
1 changed files with 5 additions and 2 deletions
|
@ -1074,16 +1074,19 @@ class OneServiceImpl : public OneService {
|
|||
auto processor = std::unique_ptr<sdktrace::SpanProcessor>(new sdktrace::BatchSpanProcessor(std::move(exporter), batch_options));
|
||||
auto processors = std::vector<std::unique_ptr<sdktrace::SpanProcessor> >();
|
||||
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<sdktrace::Sampler>(new sdktrace::TraceIdRatioBasedSampler(_exporterSampleRate));
|
||||
auto tracer_context = std::make_unique<sdktrace::TracerContext>(std::move(processors), resource, std::move(sampler));
|
||||
_traceProvider = opentelemetry::nostd::shared_ptr<sdktrace::TracerProvider>(new sdktrace::TracerProvider(std::move(tracer_context)));
|
||||
|
|
Loading…
Add table
Reference in a new issue