Opentelemetry-specification: Clarify that Sampler can be shared among TracerProvider

Created on 12 May 2021  路  7Comments  路  Source: open-telemetry/opentelemetry-specification

In #1658 it is discussed whether Sampler can be shared between different TracerProvider instances or not. In the Spec itself there's no mention of this, and we should definitely clarify this, whether this is allowed or not.

sampling sdk trace

Most helpful comment

This also needs to be clarified for exporters and spanprocessors.

All 7 comments

This also needs to be clarified for exporters and spanprocessors.

Isn't TracerProvider meant to be a singleton?

Isn't TracerProvider meant to be a singleton?

From the spec:

Notwithstanding any global TracerProvider, some applications may want to or have to use multiple TracerProvider instances, e.g. to have different configuration (like SpanProcessors) for each

cc @bogdandrutu

Discussed during the spec SIG meeting:

  1. Sampler/Processor/Exporter are all part of the SDK, the clarification on whether the same instance can be shared among multiple tracer providers is recommended/must-have should be the same.
  2. It might be too late to enforce this (e.g. by saying that samplers MUST be able to share among tracer providers), we might be able to add clarification and recommend that implementations CAN/SHOULD encourage the sharing?

@bogdandrutu need your input on this.

If we don't allow Sampler to be shared we can do improvements like pre-calculate conditions on Resource. I personally believe that every implementation of the Sampler can have its own requirement, for example a Sampler that needs access to Resource can require to not be shared.

Right now, because the usage of Resource is an edge case, I think an implementation that needs Resource right now, can take the Resource as argument in the ctor and have a limitation that can be assign to only one TracerProvider which is fine, because right now we don't say that Sampler MUST be able to be associated with multiple TracerProviders. I think that is the case for exporter and Processor

Was this page helpful?
0 / 5 - 0 ratings