-
Notifications
You must be signed in to change notification settings - Fork 670
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update instrumentors to use span processors #852
Conversation
Can you explain a bit more about what the issue is and how we are solving it? Is this a quick fix or a permanent solution? I also am confused with this: |
Sure, the problem here happens with auto instrumentation. The example from @mat-rumian in #832 used auto instrumentation to launch several scripts. Among them, this code was getting executed:
Span processors were added to the tracer, but this happened after the auto instrumentation process happened. In this process, a tracer is created (without span processors). This object is stored in a function as a closure: here and here. So, the requests and the dbapi instrumentations end up using this tracer object that lacks the span processors and that makes their spans not to be exported and that is why they were not showing up in the Jaeger exporter. This is still a draft, it could be added as a fix in the instrumentations, it will solve the issue in these two instrumentations but I think there is a bigger issue, the fact that some configuration can happen in the environment variables (configuration that is accessible to the auto instrumentation process) and some can happen in the application code (configuration that is not accessible to the auto instrumentation process, like the addition of span processors in the application code). |
Yeah, this is a behavioral issue that has bitten me a little bit to. You have to be very careful with the ordering of the creation of the required components:
To make this fool-proof, we need to ensure creation of the TracerProvider before auto-instrumentation. This is hard to do, because one typically configures their TraceProvider programatically, after the application initializes. I agree with @ocelotl that the best option is to defer tracer creation until we absolutely have to. Not sure how we can codify it though, besides documenting that practice somewhere and hoping that others will follow it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's optimizations for processor creation, but there may be value in tackling that at a higher level.
This does resolve a critical issue with trace configuration with auto-instrumentation. Thanks for the fix!
ext/opentelemetry-ext-requests/src/opentelemetry/ext/requests/__init__.py
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
bae0674
to
f104639
Compare
Fixes open-telemetry#832. By having tracer creation occur on demand, late tracer provider configuration will be honored. This resolves issues with instrumentation occurring before tracer providers are set by the application developer, which would result in the no-op tracer used for the lifetime of the instrumentation. Co-authored-by: alrex <[email protected]> Co-authored-by: Leighton Chen <[email protected]> Co-authored-by: Yusuke Tsutsumi <[email protected]>
Fixes #832
This can be implemented as a fix right now, but the issue highlights a more pressing matter, the fact that there is an overlap between configuration in the standard sense (the kind that uses
Configuration
) and the kind that is implemented by the end user as application code.