public class TracerImpl extends java.lang.Object implements ExtendedTracer
The tracer uses Timer for time measurement. inspectIT SDK provides a simple timer
implementation (SystemTimer), as it needs to be compatible with java 6.
The tracer uses Reporter for reporting finished spans. In inspectIT SDK there is an
option to explicitly state that span should not be reported, as inspectIT itself adds other
information to the span it creates and reports them itself. User created spans will always be
reported if not explicitly stated otherwise.
| Constructor and Description |
|---|
TracerImpl()
Initializes the tracer with
SystemTimer and NoopReporter. |
TracerImpl(Timer timer,
Reporter reporter,
boolean setToTracerProvider)
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
SpanBuilderImpl |
buildSpan()
Builds span with no operation name.
|
SpanBuilderImpl |
buildSpan(java.lang.String operationName) |
SpanBuilderImpl |
buildSpan(java.lang.String operationName,
java.lang.String referenceType,
boolean useThreadContext)
Creates
SpanBuilder that optionally adds the reference to the current thread context
span. |
<C> io.opentracing.SpanContext |
extract(io.opentracing.propagation.Format<C> format,
C carrier) |
SpanContextImpl |
getCurrentContext()
Returns the current thread span context if one exists.
|
<C> void |
inject(io.opentracing.SpanContext spanContext,
io.opentracing.propagation.Format<C> format,
C carrier) |
boolean |
isCurrentContextExisting()
Returns if the thread context exists.
|
<C> void |
registerPropagator(io.opentracing.propagation.Format<C> format,
Propagator<C> propagator)
Registers propagator.
|
void |
setTimer(Timer timer)
Sets the implementation of the
Timer to use. |
public TracerImpl()
SystemTimer and NoopReporter. Please use
TracerImpl(Timer, Reporter, boolean) for initialization with reporter of
your choice.public TracerImpl(Timer timer, Reporter reporter, boolean setToTracerProvider)
timer - Timerreporter - ReportersetToTracerProvider - If this tracer should be set to the TracerProvider class for static usage.public <C> void registerPropagator(io.opentracing.propagation.Format<C> format,
Propagator<C> propagator)
registerPropagator in interface ExtendedTracerC - format typeformat - opentracing Formatpropagator - Propagatorpublic SpanBuilderImpl buildSpan()
buildSpan in interface ExtendedTracerSpanBuilder.public SpanBuilderImpl buildSpan(java.lang.String operationName)
Note that as tracer is thread span context aware this method will automatically add reference
(CHILD_OF) to the current thread span context if the one exists. If you want to manually
specify reference type or want to ignore the current thread context then use
buildSpan(String, String, boolean).
buildSpan in interface io.opentracing.Tracerpublic SpanBuilderImpl buildSpan(java.lang.String operationName, java.lang.String referenceType, boolean useThreadContext)
SpanBuilder that optionally adds the reference to the current thread context
span.buildSpan in interface ExtendedTraceroperationName - Operation name of the span.referenceType - Reference type to the current context.useThreadContext - If thread context should be used.SpanBuilder.public <C> void inject(io.opentracing.SpanContext spanContext,
io.opentracing.propagation.Format<C> format,
C carrier)
inject in interface io.opentracing.Tracerpublic <C> io.opentracing.SpanContext extract(io.opentracing.propagation.Format<C> format,
C carrier)
extract in interface io.opentracing.Tracerpublic SpanContextImpl getCurrentContext()
null.
The noop tracer implementation should always return the
NoopSpanContext instance here.
getCurrentContext in interface ExtendedTracernull if thread has no such spans.public boolean isCurrentContextExisting()
public void setTimer(Timer timer)
Timer to use.
By default inspectIT tracer uses
SystemTimer that has millisecond
start time precision. This done so inspectIT can be compatible with Java 6. Users can provide
better timers if they run on higher Java versions or have third party dependencies that could
do better.
setTimer in interface ExtendedTracertimer - Timer to set. Must not be null.