Class PropagatedSpan
- All Implemented Interfaces:
Span
,ImplicitContextKeyed
Span
that is used when no Span
implementation is available. All
operations are no-op except context propagation.-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final PropagatedSpan
private final SpanContext
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds an event to theSpan
.Adds an event to theSpan
with the giventimestamp
, as nanos since epoch.addEvent
(String name, Attributes attributes) Adds an event to theSpan
with the givenAttributes
.addEvent
(String name, Attributes attributes, long timestamp, TimeUnit unit) (package private) static Span
create
(SpanContext spanContext) void
end()
Marks the end ofSpan
execution.void
Marks the end ofSpan
execution with the specified timestamp.Returns theSpanContext
associated with thisSpan
.boolean
Returnstrue
if thisSpan
records tracing events (e.g.recordException
(Throwable exception) recordException
(Throwable exception, Attributes additionalAttributes) setAllAttributes
(Attributes attributes) Sets attributes to theSpan
.<T> Span
setAttribute
(AttributeKey<T> key, T value) Sets an attribute to theSpan
.setAttribute
(String key, boolean value) Sets an attribute to theSpan
.setAttribute
(String key, double value) Sets an attribute to theSpan
.setAttribute
(String key, long value) Sets an attribute to theSpan
.setAttribute
(String key, String value) Sets an attribute to theSpan
.setStatus
(StatusCode statusCode) Sets the status to theSpan
.setStatus
(StatusCode statusCode, String description) Sets the status to theSpan
.toString()
updateName
(String name) Updates theSpan
name.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.opentelemetry.context.ImplicitContextKeyed
makeCurrent
Methods inherited from interface io.opentelemetry.api.trace.Span
addEvent, addEvent, addLink, addLink, end, setAttribute, storeInContext
-
Field Details
-
INVALID
-
spanContext
-
-
Constructor Details
-
PropagatedSpan
-
-
Method Details
-
create
-
setAttribute
Description copied from interface:Span
Sets an attribute to theSpan
. If theSpan
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
Span.setAttribute(AttributeKey, Object)
, and pre-allocate your keys, if possible.- Specified by:
setAttribute
in interfaceSpan
- Parameters:
key
- the key for this attribute.value
- the value for this attribute.- Returns:
- this.
-
setAttribute
Description copied from interface:Span
Sets an attribute to theSpan
. If theSpan
previously contained a mapping for the key, the old value is replaced by the specified value.Note: It is strongly recommended to use
Span.setAttribute(AttributeKey, Object)
, and pre-allocate your keys, if possible.- Specified by:
setAttribute
in interfaceSpan
- Parameters:
key
- the key for this attribute.value
- the value for this attribute.- Returns:
- this.
-
setAttribute
Description copied from interface:Span
Sets an attribute to theSpan
. If theSpan
previously contained a mapping for the key, the old value is replaced by the specified value.Note: It is strongly recommended to use
Span.setAttribute(AttributeKey, Object)
, and pre-allocate your keys, if possible.- Specified by:
setAttribute
in interfaceSpan
- Parameters:
key
- the key for this attribute.value
- the value for this attribute.- Returns:
- this.
-
setAttribute
Description copied from interface:Span
Sets an attribute to theSpan
. If theSpan
previously contained a mapping for the key, the old value is replaced by the specified value.Note: It is strongly recommended to use
Span.setAttribute(AttributeKey, Object)
, and pre-allocate your keys, if possible.- Specified by:
setAttribute
in interfaceSpan
- Parameters:
key
- the key for this attribute.value
- the value for this attribute.- Returns:
- this.
-
setAttribute
Description copied from interface:Span
Sets an attribute to theSpan
. If theSpan
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.
- Specified by:
setAttribute
in interfaceSpan
- Parameters:
key
- the key for this attribute.value
- the value for this attribute.- Returns:
- this.
-
setAllAttributes
Description copied from interface:Span
Sets attributes to theSpan
. If theSpan
previously contained a mapping for any of the keys, the old values are replaced by the specified values.- Specified by:
setAllAttributes
in interfaceSpan
- Parameters:
attributes
- the attributes- Returns:
- this.
-
addEvent
Description copied from interface:Span
Adds an event to theSpan
. The timestamp of the event will be the current time. -
addEvent
Description copied from interface:Span
Adds an event to theSpan
with the giventimestamp
, as nanos since epoch. Note, thistimestamp
is not the same asSystem.nanoTime()
but may be computed using it, for example, by taking a difference of readings fromSystem.nanoTime()
and adding to the span start time.When possible, it is preferred to use
Span.addEvent(String)
at the time the event occurred. -
addEvent
Description copied from interface:Span
Adds an event to theSpan
with the givenAttributes
. The timestamp of the event will be the current time. -
addEvent
Description copied from interface:Span
Adds an event to theSpan
with the givenAttributes
andtimestamp
. Note, thistimestamp
is not the same asSystem.nanoTime()
but may be computed using it, for example, by taking a difference of readings fromSystem.nanoTime()
and adding to the span start time.When possible, it is preferred to use
Span.addEvent(String)
at the time the event occurred.- Specified by:
addEvent
in interfaceSpan
- Parameters:
name
- the name of the event.attributes
- the attributes that will be added; these are associated with this event, not theSpan
as forsetAttribute()
.timestamp
- the explicit event timestamp since epoch.unit
- the unit of the timestamp- Returns:
- this.
-
setStatus
Description copied from interface:Span
Sets the status to theSpan
.If used, this will override the default
Span
status. Default status code isStatusCode.UNSET
.Only the value of the last call will be recorded, and implementations are free to ignore previous calls.
- Specified by:
setStatus
in interfaceSpan
- Parameters:
statusCode
- theStatusCode
to set.- Returns:
- this.
-
setStatus
Description copied from interface:Span
Sets the status to theSpan
.If used, this will override the default
Span
status. Default status code isStatusCode.UNSET
.Only the value of the last call will be recorded, and implementations are free to ignore previous calls.
- Specified by:
setStatus
in interfaceSpan
- Parameters:
statusCode
- theStatusCode
to set.description
- the description of theStatus
.- Returns:
- this.
-
recordException
Description copied from interface:Span
Records information about theThrowable
to theSpan
.Note that the EXCEPTION_ESCAPED value from the Semantic Conventions cannot be determined by this function. You should record this attribute manually using
Span.recordException(Throwable, Attributes)
if you know that an exception is escaping.- Specified by:
recordException
in interfaceSpan
- Parameters:
exception
- theThrowable
to record.- Returns:
- this.
-
recordException
Description copied from interface:Span
- Specified by:
recordException
in interfaceSpan
- Parameters:
exception
- theThrowable
to record.additionalAttributes
- the additionalAttributes
to record.- Returns:
- this.
-
updateName
Description copied from interface:Span
Updates theSpan
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.- Specified by:
updateName
in interfaceSpan
- Parameters:
name
- theSpan
name.- Returns:
- this.
-
end
public void end()Description copied from interface:Span
Marks the end ofSpan
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. -
end
Description copied from interface:Span
Marks the end ofSpan
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, useSpan.end()
. -
getSpanContext
Description copied from interface:Span
Returns theSpanContext
associated with thisSpan
.- Specified by:
getSpanContext
in interfaceSpan
- Returns:
- the
SpanContext
associated with thisSpan
.
-
isRecording
public boolean isRecording()Description copied from interface:Span
Returnstrue
if thisSpan
records tracing events (e.g.Span.addEvent(String)
,Span.setAttribute(String, long)
).- Specified by:
isRecording
in interfaceSpan
- Returns:
true
if thisSpan
records tracing events.
-
toString
-