Global Tracer forwarding to another Tracer implementation.
❗Note: GlobalTracer has been included in core
OpenTracing Java since opentracing-java version 0.21.0.
This contrib project is now deprecated.
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
NoopTracerwill be used.
Some examples on how this library can be used:
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);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.