You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Calling trace.get_tracer() before setting a global tracer provider effectively disables all tracing for the process.
opentelemetry.ap.trace.get_tracer_provider() checks if a global tracer provider is set or not and if not, it sets the global provider to the default implementation from the api package.
Calling opentelemetry.trace.get_tracer() internally calls get_tracer_provider() meaning if it is called before a set_tracer_provider() call, it ends up setting the global provider to the default tracer provider.
This means subsequent calls to set_provider will not do anything and no spans will be exported.
Depending on which framework the user is instrumenting or how logging is set up, this may or may not provide helpful hints.
Either move trace.get_tracer() to inside the view or move init_tracing from wsgi.py to manage.py to fix the issue.
Possible fixes
Document this and highlight it as a caveat, and hope users don't get tripped by it.
Partial fix would be for trace.set_tracer_provider() to accept new tracer provider instances and replace the old one if the old one was an instance of the default tracer provider. This would be a partial fix because it would make the trace pipeline and any tracers fetched after the pipeline was setup functional but it would still render the tracers fetched before the pipeline was setup non-functional as they'd export spans to the default tracer provider.
Patch the default tracer to actually be a proxy to a real tracer. May be the default tracer can lazily "upgrade" itself to a real tracer if an actual tracer provider was set, otherwise continue to be a noop implementation.
The text was updated successfully, but these errors were encountered:
…server and value recorder (open-telemetry#1276)
* chore: updating aggregator MinMaxLastSumCount and use it for value observer and value recorder
* chore: fix after merge
Calling
trace.get_tracer()
before setting a global tracer provider effectively disables all tracing for the process.opentelemetry.ap.trace.get_tracer_provider()
checks if a global tracer provider is set or not and if not, it sets the global provider to the default implementation from the api package.opentelemetry.trace.get_tracer()
internally callsget_tracer_provider()
meaning if it is called before aset_tracer_provider()
call, it ends up setting the global provider to the default tracer provider.Steps to reproduce
Example project: https://github.com/owais/otel-django-test
Steps
./manage.py runserver 8000
localhost:8000/hello
.Fix
trace.get_tracer()
to inside the view or move init_tracing from wsgi.py to manage.py to fix the issue.Possible fixes
trace.set_tracer_provider()
to accept new tracer provider instances and replace the old one if the old one was an instance of the default tracer provider. This would be a partial fix because it would make the trace pipeline and any tracers fetched after the pipeline was setup functional but it would still render the tracers fetched before the pipeline was setup non-functional as they'd export spans to the default tracer provider.The text was updated successfully, but these errors were encountered: