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

pack-priv final Class PropagatedSpan

extends Object
implements Span
Class Inheritance
All Implemented Interfaces
io.opentelemetry.api.trace.Span, io.opentelemetry.context.ImplicitContextKeyed
Annotations
@Immutable
Imports
io.opentelemetry.api.common.AttributeKey, .Attributes, java.util.concurrent.TimeUnit, javax.annotation.concurrent.Immutable

The default Span that is used when no Span implementation is available. All operations are no-op except context propagation.

Field Summary

Modifier and TypeField and Description
pack-priv static final PropagatedSpan
private final SpanContext

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public Span
addEvent(String
the name of the event.
name
)

Overrides default io.opentelemetry.api.trace.Span.addEvent.

Adds an event to the Span.

public Span
addEvent(String
the name of the event.
name
,
long
the explicit event timestamp since epoch.
timestamp
,
TimeUnit
the unit of the timestamp
unit
)

Overrides default io.opentelemetry.api.trace.Span.addEvent.

Adds an event to the Span with the given timestamp, as nanos since epoch.

public Span
addEvent(String
the name of the event.
name
,
Attributes
the attributes that will be added; these are associated with this event, not the Span as for setAttribute().
attributes
)

Implements io.opentelemetry.api.trace.Span.addEvent.

Adds an event to the Span with the given Attributes.

public Span
addEvent(String
the name of the event.
name
,
Attributes
the attributes that will be added; these are associated with this event, not the Span as for setAttribute().
attributes
,
long
the explicit event timestamp since epoch.
timestamp
,
TimeUnit
the unit of the timestamp
unit
)

Implements io.opentelemetry.api.trace.Span.addEvent.

Adds an event to the Span with the given Attributes and timestamp.

pack-priv static Span
create(SpanContext spanContext)

public void
end()

Implements io.opentelemetry.api.trace.Span.end.

Marks the end of Span execution.

public void
end(long
the explicit timestamp from the epoch, for this Span. 0 indicates current time should be used.
timestamp
,
TimeUnit
the unit of the timestamp
unit
)

Implements io.opentelemetry.api.trace.Span.end.

Marks the end of Span execution with the specified timestamp.

public SpanContext
getSpanContext()

Implements io.opentelemetry.api.trace.Span.getSpanContext.

Returns the SpanContext associated with this Span.

public boolean
isRecording()

Implements io.opentelemetry.api.trace.Span.isRecording.

Returns true if this Span records tracing events (e.g. addEvent(String), setAttribute(String, long)).

public Span
recordException(Throwable
the Throwable to record.
exception
)

Overrides default io.opentelemetry.api.trace.Span.recordException.

Records information about the Throwable to the Span.

public Span
recordException(Throwable
the Throwable to record.
exception
,
Attributes
the additional Attributes to record.
additionalAttributes
)

Implements io.opentelemetry.api.trace.Span.recordException.

Records information about the Throwable to the Span.

public Span
setAllAttributes(Attributes
the attributes
attributes
)

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

Sets attributes to the Span.

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

Overrides default io.opentelemetry.api.trace.Span.setAttribute.

Sets an attribute to the Span.

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

Overrides default io.opentelemetry.api.trace.Span.setAttribute.

Sets an attribute to the Span.

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

Overrides default io.opentelemetry.api.trace.Span.setAttribute.

Sets an attribute to the Span.

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

Overrides default io.opentelemetry.api.trace.Span.setAttribute.

Sets an attribute to the Span.

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

Implements io.opentelemetry.api.trace.Span.setAttribute.

Sets an attribute to the Span.

public Span
setStatus(StatusCode
the StatusCode to set.
statusCode
)

Overrides default io.opentelemetry.api.trace.Span.setStatus.

Sets the status to the Span.

public Span
setStatus(StatusCode
the StatusCode to set.
statusCode
,
String
the description of the Status.
description
)

Implements io.opentelemetry.api.trace.Span.setStatus.

Sets the status to the Span.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public Span
updateName(String
the Span name.
name
)

Implements io.opentelemetry.api.trace.Span.updateName.

Updates the Span name.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

INVALIDback to summary
pack-priv static final PropagatedSpan INVALID
spanContextback to summary
private final SpanContext spanContext

Constructor Detail

PropagatedSpanback to summary
private PropagatedSpan(SpanContext spanContext)

Method Detail

addEventback to summary
public Span addEvent(String name)

Overrides default io.opentelemetry.api.trace.Span.addEvent.

Doc from io.opentelemetry.api.trace.Span.addEvent.

Adds an event to the Span. The timestamp of the event will be the current time.

Parameters
name:String

the name of the event.

Returns:Span

this.

Annotations
@Override
addEventback to summary
public Span addEvent(String name, long timestamp, TimeUnit unit)

Overrides default io.opentelemetry.api.trace.Span.addEvent.

Doc from io.opentelemetry.api.trace.Span.addEvent.

Adds an event to the Span with the given timestamp, as nanos since epoch. Note, this timestamp is not the same as System#nanoTime() but may be computed using it, for example, by taking a difference of readings from System#nanoTime() and adding to the span start time.

When possible, it is preferred to use addEvent(String) at the time the event occurred.

Parameters
name:String

the name of the event.

timestamp:long

the explicit event timestamp since epoch.

unit:TimeUnit

the unit of the timestamp

Returns:Span

this.

Annotations
@Override
addEventback to summary
public Span addEvent(String name, Attributes attributes)

Implements io.opentelemetry.api.trace.Span.addEvent.

Doc from io.opentelemetry.api.trace.Span.addEvent.

Adds an event to the Span with the given Attributes. The timestamp of the event will be the current time.

Parameters
name:String

the name of the event.

attributes:Attributes

the attributes that will be added; these are associated with this event, not the Span as for setAttribute().

Returns:Span

this.

Annotations
@Override
addEventback to summary
public Span addEvent(String name, Attributes attributes, long timestamp, TimeUnit unit)

Implements io.opentelemetry.api.trace.Span.addEvent.

Doc from io.opentelemetry.api.trace.Span.addEvent.

Adds an event to the Span with the given Attributes and timestamp. Note, this timestamp is not the same as System#nanoTime() but may be computed using it, for example, by taking a difference of readings from System#nanoTime() and adding to the span start time.

When possible, it is preferred to use addEvent(String) at the time the event occurred.

Parameters
name:String

the name of the event.

attributes:Attributes

the attributes that will be added; these are associated with this event, not the Span as for setAttribute().

timestamp:long

the explicit event timestamp since epoch.

unit:TimeUnit

the unit of the timestamp

Returns:Span

this.

Annotations
@Override
createback to summary
pack-priv static Span create(SpanContext spanContext)
endback to summary
public void end()

Implements io.opentelemetry.api.trace.Span.end.

Doc from io.opentelemetry.api.trace.Span.end.

Marks the end of Span execution.

Only the timing of the first end call for a given Span will be recorded, and implementations are free to ignore all further calls.

Annotations
@Override
endback to summary
public void end(long timestamp, TimeUnit unit)

Implements io.opentelemetry.api.trace.Span.end.

Doc from io.opentelemetry.api.trace.Span.end.

Marks the end of Span execution with the specified timestamp.

Only the timing of the first end call for a given Span will be recorded, and implementations are free to ignore all further calls.

Use this method for specifying explicit end options, such as end Timestamp. When no explicit values are required, use end().

Parameters
timestamp:long

the explicit timestamp from the epoch, for this Span. 0 indicates current time should be used.

unit:TimeUnit

the unit of the timestamp

Annotations
@Override
getSpanContextback to summary
public SpanContext getSpanContext()

Implements io.opentelemetry.api.trace.Span.getSpanContext.

Doc from io.opentelemetry.api.trace.Span.getSpanContext.

Returns the SpanContext associated with this Span.

Returns:SpanContext

the SpanContext associated with this Span.

Annotations
@Override
isRecordingback to summary
public boolean isRecording()

Implements io.opentelemetry.api.trace.Span.isRecording.

Doc from io.opentelemetry.api.trace.Span.isRecording.

Returns true if this Span records tracing events (e.g. addEvent(String), setAttribute(String, long)).

Returns:boolean

true if this Span records tracing events.

Annotations
@Override
recordExceptionback to summary
public Span recordException(Throwable exception)

Overrides default io.opentelemetry.api.trace.Span.recordException.

Doc from io.opentelemetry.api.trace.Span.recordException.

Records information about the Throwable to the Span.

Note that the EXCEPTION_ESCAPED value from the Semantic Conventions cannot be determined by this function. You should record this attribute manually using recordException(Throwable, Attributes) if you know that an exception is escaping.

Parameters
exception:Throwable

the Throwable to record.

Returns:Span

this.

Annotations
@Override
recordExceptionback to summary
public Span recordException(Throwable exception, Attributes additionalAttributes)

Implements io.opentelemetry.api.trace.Span.recordException.

Doc from io.opentelemetry.api.trace.Span.recordException.

Records information about the Throwable to the Span.

Parameters
exception:Throwable

the Throwable to record.

additionalAttributes:Attributes

the additional Attributes to record.

Returns:Span

this.

Annotations
@Override
setAllAttributesback to summary
public Span setAllAttributes(Attributes attributes)

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

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

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

Parameters
attributes:Attributes

the attributes

Returns:Span

this.

Annotations
@Override
setAttributeback to summary
public Span setAttribute(String key, String value)

Overrides default io.opentelemetry.api.trace.Span.setAttribute.

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

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

Empty String "" and null are valid attribute value, but not valid keys.

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:Span

this.

Annotations
@Override
setAttributeback to summary
public Span setAttribute(String key, long value)

Overrides default io.opentelemetry.api.trace.Span.setAttribute.

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

Sets an attribute to the Span. If the Span 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:Span

this.

Annotations
@Override
setAttributeback to summary
public Span setAttribute(String key, double value)

Overrides default io.opentelemetry.api.trace.Span.setAttribute.

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

Sets an attribute to the Span. If the Span 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:Span

this.

Annotations
@Override
setAttributeback to summary
public Span setAttribute(String key, boolean value)

Overrides default io.opentelemetry.api.trace.Span.setAttribute.

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

Sets an attribute to the Span. If the Span 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:Span

this.

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

Implements io.opentelemetry.api.trace.Span.setAttribute.

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

Sets an attribute to the Span. If the Span 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:Span

this.

Annotations
@Override
setStatusback to summary
public Span setStatus(StatusCode statusCode)

Overrides default io.opentelemetry.api.trace.Span.setStatus.

Doc from io.opentelemetry.api.trace.Span.setStatus.

Sets the status to the Span.

If used, this will override the default Span status. Default status code is StatusCode#UNSET.

Only the value of the last call will be recorded, and implementations are free to ignore previous calls.

Parameters
statusCode:StatusCode

the StatusCode to set.

Returns:Span

this.

Annotations
@Override
setStatusback to summary
public Span setStatus(StatusCode statusCode, String description)

Implements io.opentelemetry.api.trace.Span.setStatus.

Doc from io.opentelemetry.api.trace.Span.setStatus.

Sets the status to the Span.

If used, this will override the default Span status. Default status code is StatusCode#UNSET.

Only the value of the last call will be recorded, and implementations are free to ignore previous calls.

Parameters
statusCode:StatusCode

the StatusCode to set.

description:String

the description of the Status.

Returns:Span

this.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
updateNameback to summary
public Span updateName(String name)

Implements io.opentelemetry.api.trace.Span.updateName.

Doc from io.opentelemetry.api.trace.Span.updateName.

Updates the Span name.

If used, this will override the name provided via Span.Builder.

Upon this update, any sampling behavior based on Span name will depend on the implementation.

Parameters
name:String

the Span name.

Returns:Span

this.

Annotations
@Override