public final class GlobalTracer extends Object implements Tracer
register(Tracer).
The register method should only be called once
during the application initialization phase.
If the register method is never called,
the default NoopTracer is used.
Tracer.SpanBuilder| Modifier and Type | Method and Description |
|---|---|
Tracer.SpanBuilder |
buildSpan(String operationName) |
<C> SpanContext |
extract(Format<C> format,
C carrier) |
static Tracer |
get()
Returns the constant GlobalTracer.
|
<C> void |
inject(SpanContext spanContext,
Format<C> format,
C carrier) |
static boolean |
isRegistered()
Identify whether a
Tracer has previously been registered. |
static void |
register(Tracer tracer)
Register a
Tracer to back the behaviour of the global tracer. |
String |
toString() |
public static Tracer get()
All methods are forwarded to the currently configured tracer.
Until a tracer is explicitly configured,
the NoopTracer is used.
register(Tracer)public static void register(Tracer tracer)
Tracer to back the behaviour of the global tracer.
Registration is a one-time operation, attempting to call it more often will result in a runtime exception.
Every application intending to use the global tracer is responsible for registering it once during its initialization.
tracer - Tracer to use as global tracer.RuntimeException - if there is already a current tracer registeredpublic static boolean isRegistered()
Tracer has previously been registered.
This check is useful in scenarios where more than one component may be responsible for registering a tracer. For example, when using a Java Agent, it will need to determine if the application has already registered a tracer, and if not attempt to resolve and register one itself.
public Tracer.SpanBuilder buildSpan(String operationName)
public <C> void inject(SpanContext spanContext, Format<C> format, C carrier)
public <C> SpanContext extract(Format<C> format, C carrier)
Copyright © 2016–2017 OpenTracing. All rights reserved.