-
Notifications
You must be signed in to change notification settings - Fork 179
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
refactor: Default to Proxy Tracer in instrumentations #688
refactor: Default to Proxy Tracer in instrumentations #688
Conversation
While working on open-telemetry#677, I ran into an issue where the base instrumentation tracer was not being automatically upgraded after the SDK initialization was complete. I am not sure why this was implemented this way but I figured other instrumentations would need a reference to a proxy tracer in the future. open-telemetry/opentelemetry-ruby#671
The key point in @robertlaurin's PR was:
Auto-instrumentation has a no-op tracer until it is properly installed. If it is never installed, (naive) instrumentation code can still use the tracer without creating spans and without repeatedly checking if the instrumentation is installed. The change in this PR will upgrade the tracer to create spans when the SDK is installed, even if the instrumentation is not installed, so naive instrumentation code would have to be less naive, checking if it has been installed before using the named tracer. It's worth debating whether this is useful in practice. I believe all our instrumentation explicitly monkey-patches or registers hooks only when installed. I think the original PR was aimed at supporting first-party instrumentation with the same framework (for config, in particular). |
Also, to be clear, this represents a change in behaviour, so not really a |
It would be helpful to me to see a use case where we saw this cause a problem. I feel like I am missing something here based on your explanation. Assuming first-part instrumentation were to exists and they derived their instrumentation classes from Base, then their instrumentation would be automatically registered with the SDK1 and would need to adhere to the Base classes auto-installation lifecycle methods to avoid running into issues. If for some reason they reimplemented First party implementers that decide to deviate from this pattern, e.g. override methods in If someone did use Is there something else or another use case that I have overlooked? I chose Footnotes
|
Sorry for the slow response, any reason why we can do a simple revert of https://github.com/open-telemetry/opentelemetry-ruby/pull/671/files ? Expanding a bit here, it seems like a revert opens an issue where any consumers of base trying to access a tracer before the install hook fires will have a problem. |
Reverting a commit is a-ok with me. Would you mind sharing more context of how 1P implementers are accessing the tracer before the instrumentation instance is initialized? |
We discussed this at length on the sig, but there isn't any good example. It might be better to frame the competing ideas here as:
I'm in the camp that a tracer should not be upgraded in the event that the instrumentation install fails. Commentary from Francis
So lets assume we have some misbehaving instrumentation that is unconditionally using the instance tracer regardless of the install being successful or not. If we always upgrade all tracers, you'll get spans you did not expect. If you conditionally upgrade the trace, you won't get the spans you didn't expect, but may end up with the behaviour of a broken trace as there may be noop spans scattered in. I think because we're dealing with hypothetical abuses of instrumentation instances here, it's hard to make a really strong argument for or against either behaviour. I continue to be in favour of the following because the behaviour feels more "predictable" or "expected".
|
While working on #677, I ran into an issue where the base instrumentation tracer was not being automatically upgraded after the SDK initialization was complete.
I am not sure why this was implemented this way but I figured other instrumentations would need a reference to a proxy tracer in the future.
open-telemetry/opentelemetry-ruby#671