❗
deprecated
❗
Global tracer resolution for Java
Global Tracer forwarding to another Tracer implementation.
GlobalTracer
has been included in core OpenTracing Java since opentracing-java version 0.21.0
.
This contrib project is now deprecated.
GlobalTracer
Provides the GlobalTracer.get()
method that returns the singleton global tracer.
When the tracer is needed it is lazily looked up using the following rules:
- The tracer from the last
register(tracer)
call always takes precedence. - If no tracer was registered, one is resolved by the TracerResolver.
- If no Tracer is resolved, the
NoopTracer
will be used.
How to use this library
Some examples on how this library can be used:
Application intialization
Initialize a new tracer from the application configuration and let it to become the GlobalTracer
for the application:
Tracer configuredTracer = applicationConfiguration.buildConfiguredTracer();
GlobalTracer.register(configuredTracer);
Using the global tracer
Once initialized, all application code can instrument tracing by starting new spans like:
try (Span span = GlobalTracer.get().buildSpan("someOperation").start()) {
// ... Traced block of code ...
}
If no GlobalTracer is configured, this code will not throw any exceptions. Tracing is simply delegated to the NoopTracer
instead.