-
Notifications
You must be signed in to change notification settings - Fork 345
Access Custom Tracer's fields through GlobalTracer.get() #365
Comments
The GlobalTracer -by design- only exposes the OpenTracing API. Technically it also helps reason about the state in an uninitialized application but that is secondary. Unfortunately this also means that you cannot simply cast the globaltracer to any specific implementation; if you need a specific implementation you should create your own construct to access it. Technically some kind of 'unwrap' may be possible, but I don't know how other contributors feel about that. Documenting such unwrap method is harder than it looks as it may return unpredictable results during GlobalTracer registration. |
My two cents: Don't use |
Yes, I completely forgot go mention this ⬆️ ; the GlobalTracer is intended for libraries that have no dependency injection; so by all means set it at application initialisation, but try to avoid using it yourself if at all possible. |
The documentation says that Global tracer forwards all of its methods to registered tracer. But I don't see any use of that by preventing users from using the registered tracer. |
I have Created my custom tracer and added some methods to it. Now If I register a tracer on GlobalTracer and try to retrieve it using Globaltracer.get() I am getting an instance of GlobalTracer.
The tracer which I have passed is stored in tracer field of GlobalTracer but I don't see any api to access that tracer.
How can I access methods written in my custom tracer?
The text was updated successfully, but these errors were encountered: