Global Tracer resolution

Library to obtain a Tracer reference from anywhere in your application

License

License

GroupId

GroupId

io.opentracing.contrib
ArtifactId

ArtifactId

opentracing-globaltracer
Last Version

Last Version

0.1.2
Release Date

Release Date

Type

Type

jar
Description

Description

Global Tracer resolution
Library to obtain a Tracer reference from anywhere in your application
Project URL

Project URL

https://github.com/opentracing-contrib/java-globaltracer
Source Code Management

Source Code Management

https://github.com/opentracing-contrib/java-globaltracer

Download opentracing-globaltracer

How to add to project

<!-- https://jarcasting.com/artifacts/io.opentracing.contrib/opentracing-globaltracer/ -->
<dependency>
    <groupId>io.opentracing.contrib</groupId>
    <artifactId>opentracing-globaltracer</artifactId>
    <version>0.1.2</version>
</dependency>
// https://jarcasting.com/artifacts/io.opentracing.contrib/opentracing-globaltracer/
implementation 'io.opentracing.contrib:opentracing-globaltracer:0.1.2'
// https://jarcasting.com/artifacts/io.opentracing.contrib/opentracing-globaltracer/
implementation ("io.opentracing.contrib:opentracing-globaltracer:0.1.2")
'io.opentracing.contrib:opentracing-globaltracer:jar:0.1.2'
<dependency org="io.opentracing.contrib" name="opentracing-globaltracer" rev="0.1.2">
  <artifact name="opentracing-globaltracer" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.opentracing.contrib', module='opentracing-globaltracer', version='0.1.2')
)
libraryDependencies += "io.opentracing.contrib" % "opentracing-globaltracer" % "0.1.2"
[io.opentracing.contrib/opentracing-globaltracer "0.1.2"]

Dependencies

compile (4)

Group / Artifact Type Version
io.opentracing : opentracing-api jar 0.22.0
io.opentracing : opentracing-noop jar 0.22.0
io.opentracing : opentracing-util jar 0.22.0
io.opentracing.contrib : opentracing-tracerresolver jar 0.1.0

test (4)

Group / Artifact Type Version
io.opentracing : opentracing-mock jar 0.22.0
junit : junit jar 4.12
org.hamcrest : hamcrest-library jar 1.3
org.mockito : mockito-all jar 1.10.19

Project Modules

There are no modules declared in this project.

Build Status Released Version

deprecated Global tracer resolution for Java

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.

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:

  1. The tracer from the last register(tracer) call always takes precedence.
  2. If no tracer was registered, one is resolved by the TracerResolver.
  3. 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.

io.opentracing.contrib

3rd-Party OpenTracing API Contributions

3rd-party contributions that use OpenTracing. **The repositories in this org are *not* affiliated with the CNCF.**

Versions

Version
0.1.2
0.1.1
0.1.0