Description
As the discussion about this on #11 is getting quite long (#11 (comment)), I opened this issue.
Basically, opentelemetry-python should provide some API that decouples code that just wants to use instrumentation/tracing APIs from any particular tracer implementation. Without such an API, one is forced (or at least tempted) to write code like:
from opentelemetry.sdk.trace import tracer # *** Hard-coded dependency on implemenation
# Create a new root span, set it as the current span in context
with tracer.start_span("parent"):
pass # Do work
I think it is clear that we want to avoid that, as it would force a whole dependency tree of an application and its libraries to coordinate on a particular implementation of the API, which kinda defeats the purpose of having a separate API layer.
OpenTracing handles this by providing a global tracer object: https://github.com/opentracing/opentracing-python/blob/master/opentracing/__init__.py
OpenTelemetry-java also has a global OpenTelemetry
instance that, among other things, holds a reference to a global tracer: https://github.com/open-telemetry/opentelemetry-java/blob/fb0f5339cd1d665a98996806f45c60c65f47d7b6/api/src/main/java/io/opentelemetry/OpenTelemetry.java#L49-L58
There are other options, like having libraries themselves manage their "library-global" tracers. This was also discussed in a different thread #11 (comment).