-
Notifications
You must be signed in to change notification settings - Fork 848
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
Consider not using statics everywhere #1873
Comments
Please see here: open-telemetry/opentelemetry-specification#1063 (comment) and the links from there. The problem with the previous solution was also that using the tracer was only one possibility, so even if you replace that implementation, code could also be using TracingContextUtils directly which would result in a mess. |
Fair enough I'll hide the statics in my API then. We'll see how it goes once open-telemetry/opentelemetry-java-instrumentation#1464 gets finished and the code will compile again. |
@marcingrzejszczak Can you describe the reason for exposing current context on tracer? Is it to mock the method in tests? If so, what if you just use the normal context API in the tests? It's not very expensive or complex I think. Just want to better understand what you're thinking :) For reference, the armeria brave integration implements |
Brave users are accustomed to it and by injecting |
Not a strong opinion at this point, but FYI this is exactly why Ruby kept the operations in |
There were differing opinions, also for ruby: open-telemetry/opentelemetry-specification#1063 (comment) |
@Oberon00 Although I'd think that at least you still have everything in the |
I think we must not add it to tracers, this causes confusion, e.g. to open-telemetry/opentelemetry-specification#586. We could add it to TracerProvider, but then that should be the one and only possibility to get the active span. And that would be worth a spec update. |
Using statics requires everyone (at least in the Java world) to create a wrapper around that static method to stub it out. I don't think that it's a good idea and it's counter-intuitive. AFAIR @anuraaga has created some non-static methods on |
Closing, since we now fully support instance-based OpenTelemetry access, and the static global is purely optional. |
Is your feature request related to a problem? Please describe.
The current
0.10.0
version is using a lot of static callsvs 0.9.1
Also the whole Context API is done via statics - it's difficult to put in place any other implementation for testing purposes for example. You can check Brave's
CurrentTraceContext
API for reference on how they did this.Describe the solution you'd like
Using the tracer to retrieve the current span was a much better idea. I don't understand the rationale behind such changes.
Describe alternatives you've considered
I have to wrap the static calls into my own abstractions so that the users don't have to call statics.
The text was updated successfully, but these errors were encountered: