Top Description Inners Fields Constructors Methods
io.opentelemetry.api.trace

pack-priv final Class DefaultTracer

extends Object
implements Tracer
Class Inheritance
All Implemented Interfaces
io.opentelemetry.api.trace.Tracer
Annotations
@ThreadSafe
Imports
io.opentelemetry.api.common.AttributeKey, .Attributes, io.opentelemetry.api.internal.ApiUsageLogger, io.opentelemetry.context.Context, java.util.concurrent.TimeUnit, javax.annotation.Nullable, javax.annotation.concurrent.ThreadSafe

No-op implementation of Tracer.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private static final Tracer

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv static Tracer
public SpanBuilder
spanBuilder(String
The name of the returned Span.
spanName
)

Implements io.opentelemetry.api.trace.Tracer.spanBuilder.

Returns a SpanBuilder to create and start a new Span.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

INSTANCEback to summary
private static final Tracer INSTANCE

Constructor Detail

DefaultTracerback to summary
private DefaultTracer()

Method Detail

getInstanceback to summary
pack-priv static Tracer getInstance()
spanBuilderback to summary
public SpanBuilder spanBuilder(String spanName)

Implements io.opentelemetry.api.trace.Tracer.spanBuilder.

Doc from io.opentelemetry.api.trace.Tracer.spanBuilder.

Returns a SpanBuilder to create and start a new Span.

See SpanBuilder for usage examples.

Parameters
spanName:String

The name of the returned Span.

Returns:SpanBuilder

a Span.Builder to create and start a new Span.

Annotations
@Override
io.opentelemetry.api.trace back to summary

private final Class DefaultTracer.NoopSpanBuilder

extends Object
implements SpanBuilder
Class Inheritance
All Implemented Interfaces
io.opentelemetry.api.trace.SpanBuilder

Field Summary

Modifier and TypeField and Description
private SpanContext

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv static DefaultTracer.NoopSpanBuilder
public DefaultTracer.NoopSpanBuilder
setAllAttributes(Attributes
the attributes
attributes
)

Overrides default io.opentelemetry.api.trace.SpanBuilder.setAllAttributes.

Sets attributes to the SpanBuilder.

public DefaultTracer.NoopSpanBuilder
setAttribute(String
the key for this attribute.
key
,
String
the value for this attribute.
value
)

Implements io.opentelemetry.api.trace.SpanBuilder.setAttribute.

Sets an attribute to the newly created Span.

public DefaultTracer.NoopSpanBuilder
setAttribute(String
the key for this attribute.
key
,
long
the value for this attribute.
value
)

Implements io.opentelemetry.api.trace.SpanBuilder.setAttribute.

Sets an attribute to the newly created Span.

public DefaultTracer.NoopSpanBuilder
setAttribute(String
the key for this attribute.
key
,
double
the value for this attribute.
value
)

Implements io.opentelemetry.api.trace.SpanBuilder.setAttribute.

Sets an attribute to the newly created Span.

public DefaultTracer.NoopSpanBuilder
setAttribute(String
the key for this attribute.
key
,
boolean
the value for this attribute.
value
)

Implements io.opentelemetry.api.trace.SpanBuilder.setAttribute.

Sets an attribute to the newly created Span.

public <T> DefaultTracer.NoopSpanBuilder
setAttribute(AttributeKey<T>
the key for this attribute.
key
,
T
the value for this attribute.
value
)

Implements io.opentelemetry.api.trace.SpanBuilder.setAttribute.

Sets an attribute to the newly created Span.

public DefaultTracer.NoopSpanBuilder
setNoParent()

Implements io.opentelemetry.api.trace.SpanBuilder.setNoParent.

Sets the option to become a root Span for a new trace.

public DefaultTracer.NoopSpanBuilder
setParent(Context
the Context.
context
)

Implements io.opentelemetry.api.trace.SpanBuilder.setParent.

Sets the parent to use from the specified Context.

public DefaultTracer.NoopSpanBuilder
setSpanKind(SpanKind
the kind of the newly created Span.
spanKind
)

Implements io.opentelemetry.api.trace.SpanBuilder.setSpanKind.

Sets the SpanKind for the newly created Span.

public DefaultTracer.NoopSpanBuilder
setStartTimestamp(long
the explicit start timestamp from the epoch of the newly created Span.
startTimestamp
,
TimeUnit
the unit of the timestamp.
unit
)

Implements io.opentelemetry.api.trace.SpanBuilder.setStartTimestamp.

Sets an explicit start timestamp for the newly created Span.

public Span
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

spanContextback to summary
private SpanContext spanContext
Annotations
@Nullable

Constructor Detail

NoopSpanBuilderback to summary
private NoopSpanBuilder()

Method Detail

createback to summary
pack-priv static DefaultTracer.NoopSpanBuilder create()
setAllAttributesback to summary
public DefaultTracer.NoopSpanBuilder setAllAttributes(Attributes attributes)

Overrides default io.opentelemetry.api.trace.SpanBuilder.setAllAttributes.

Doc from io.opentelemetry.api.trace.SpanBuilder.setAllAttributes.

Sets attributes to the SpanBuilder. If the SpanBuilder previously contained a mapping for any of the keys, the old values are replaced by the specified values.

Parameters
attributes:Attributes

the attributes

Returns:DefaultTracer.NoopSpanBuilder

this.

Annotations
@Override
setAttributeback to summary
public DefaultTracer.NoopSpanBuilder setAttribute(String key, String value)

Implements io.opentelemetry.api.trace.SpanBuilder.setAttribute.

Doc from io.opentelemetry.api.trace.SpanBuilder.setAttribute.

Sets an attribute to the newly created Span. If SpanBuilder previously contained a mapping for the key, the old value is replaced by the specified value.

If a null or empty String value is passed in, the behavior is undefined, and hence strongly discouraged.

Note

It is strongly recommended to use setAttribute(AttributeKey, Object), and pre-allocate your keys, if possible.

Parameters
key:String

the key for this attribute.

value:String

the value for this attribute.

Returns:DefaultTracer.NoopSpanBuilder

this.

Annotations
@Override
setAttributeback to summary
public DefaultTracer.NoopSpanBuilder setAttribute(String key, long value)

Implements io.opentelemetry.api.trace.SpanBuilder.setAttribute.

Doc from io.opentelemetry.api.trace.SpanBuilder.setAttribute.

Sets an attribute to the newly created Span. If SpanBuilder previously contained a mapping for the key, the old value is replaced by the specified value.

Note

It is strongly recommended to use setAttribute(AttributeKey, Object), and pre-allocate your keys, if possible.

Parameters
key:String

the key for this attribute.

value:long

the value for this attribute.

Returns:DefaultTracer.NoopSpanBuilder

this.

Annotations
@Override
setAttributeback to summary
public DefaultTracer.NoopSpanBuilder setAttribute(String key, double value)

Implements io.opentelemetry.api.trace.SpanBuilder.setAttribute.

Doc from io.opentelemetry.api.trace.SpanBuilder.setAttribute.

Sets an attribute to the newly created Span. If SpanBuilder previously contained a mapping for the key, the old value is replaced by the specified value.

Note

It is strongly recommended to use setAttribute(AttributeKey, Object), and pre-allocate your keys, if possible.

Parameters
key:String

the key for this attribute.

value:double

the value for this attribute.

Returns:DefaultTracer.NoopSpanBuilder

this.

Annotations
@Override
setAttributeback to summary
public DefaultTracer.NoopSpanBuilder setAttribute(String key, boolean value)

Implements io.opentelemetry.api.trace.SpanBuilder.setAttribute.

Doc from io.opentelemetry.api.trace.SpanBuilder.setAttribute.

Sets an attribute to the newly created Span. If SpanBuilder previously contained a mapping for the key, the old value is replaced by the specified value.

Note

It is strongly recommended to use setAttribute(AttributeKey, Object), and pre-allocate your keys, if possible.

Parameters
key:String

the key for this attribute.

value:boolean

the value for this attribute.

Returns:DefaultTracer.NoopSpanBuilder

this.

Annotations
@Override
setAttributeback to summary
public <T> DefaultTracer.NoopSpanBuilder setAttribute(AttributeKey<T> key, T value)

Implements io.opentelemetry.api.trace.SpanBuilder.setAttribute.

Doc from io.opentelemetry.api.trace.SpanBuilder.setAttribute.

Sets an attribute to the newly created Span. If SpanBuilder previously contained a mapping for the key, the old value is replaced by the specified value.

Note

the behavior of null values is undefined, and hence strongly discouraged.

Parameters
key:AttributeKey<T>

the key for this attribute.

value:T

the value for this attribute.

Returns:DefaultTracer.NoopSpanBuilder

this.

Annotations
@Override
setNoParentback to summary
public DefaultTracer.NoopSpanBuilder setNoParent()

Implements io.opentelemetry.api.trace.SpanBuilder.setNoParent.

Doc from io.opentelemetry.api.trace.SpanBuilder.setNoParent.

Sets the option to become a root Span for a new trace. If not set, the value of Span.current() at startSpan() time will be used as parent.

Observe that any previously set parent will be discarded.

Returns:DefaultTracer.NoopSpanBuilder

this.

Annotations
@Override
setParentback to summary
public DefaultTracer.NoopSpanBuilder setParent(Context context)

Implements io.opentelemetry.api.trace.SpanBuilder.setParent.

Doc from io.opentelemetry.api.trace.SpanBuilder.setParent.

Sets the parent to use from the specified Context. If not set, the value of Span.current() at startSpan() time will be used as parent.

If no Span is available in the specified Context, the resulting Span will become a root instance, as if setNoParent() had been called.

If called multiple times, only the last specified value will be used. Observe that the state defined by a previous call to setNoParent() will be discarded.

Parameters
context:Context

the Context.

Returns:DefaultTracer.NoopSpanBuilder

this.

Annotations
@Override
setSpanKindback to summary
public DefaultTracer.NoopSpanBuilder setSpanKind(SpanKind spanKind)

Implements io.opentelemetry.api.trace.SpanBuilder.setSpanKind.

Doc from io.opentelemetry.api.trace.SpanBuilder.setSpanKind.

Sets the SpanKind for the newly created Span. If not called, the implementation will provide a default value SpanKind#INTERNAL.

Parameters
spanKind:SpanKind

the kind of the newly created Span.

Returns:DefaultTracer.NoopSpanBuilder

this.

Annotations
@Override
setStartTimestampback to summary
public DefaultTracer.NoopSpanBuilder setStartTimestamp(long startTimestamp, TimeUnit unit)

Implements io.opentelemetry.api.trace.SpanBuilder.setStartTimestamp.

Doc from io.opentelemetry.api.trace.SpanBuilder.setStartTimestamp.

Sets an explicit start timestamp for the newly created Span.

LIRInstruction.Use this method to specify an explicit start timestamp. If not called, the implementation will use the timestamp value at startSpan() time, which should be the default case.

Important this is NOT equivalent with System.nanoTime().

Parameters
startTimestamp:long

the explicit start timestamp from the epoch of the newly created Span.

unit:TimeUnit

the unit of the timestamp.

Returns:DefaultTracer.NoopSpanBuilder

this.

Annotations
@Override
startSpanback to summary
public Span startSpan()

Implements io.opentelemetry.api.trace.SpanBuilder.startSpan.

Doc from io.opentelemetry.api.trace.SpanBuilder.startSpan.

Starts a new Span.

Users must manually call Span#end() to end this Span.

Does not install the newly created Span to the current Context.

Important Note

This method can be called only once per SpanBuilder instance and as the last method called. After this method is called calling any method is undefined behavior.

Example of usage:

class MyClass {
  private final Tracer tracer;

  MyClass(OpenTelemetry openTelemetry) {
    tracer = openTelemetry.getTracer("com.example.rpc");
  }

  void doWork(Span parent) {
    Span childSpan = tracer.spanBuilder("MyChildSpan")
         .setParent(Context.current().with(parent))
         .startSpan();
    childSpan.addEvent("my event");
    try {
      doSomeWork(childSpan); // Manually propagate the new span down the stack.
    } finally {
      // To make sure we end the span even in case of an exception.
      childSpan.end();  // Manually end the span.
    }
  }
}
Returns:Span

the newly created Span.

Annotations
@Override