Interface ReadableSpan
-
- All Known Subinterfaces:
ReadWriteSpan
- All Known Implementing Classes:
SdkSpan
public interface ReadableSpan
SDK representation of aSpan
that can be read.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description <T> T
getAttribute(AttributeKey<T> key)
Returns the value for the givenAttributeKey
, ornull
if not found.default Attributes
getAttributes()
Returns the Span attributes.InstrumentationLibraryInfo
getInstrumentationLibraryInfo()
Deprecated.default InstrumentationScopeInfo
getInstrumentationScopeInfo()
Returns the instrumentation scope specified when creating the tracer which produced this span.SpanKind
getKind()
Returns the kind of the span.long
getLatencyNanos()
Returns the latency of theSpan
in nanos.java.lang.String
getName()
Returns the name of theSpan
.SpanContext
getParentSpanContext()
SpanContext
getSpanContext()
Returns theSpanContext
of theSpan
.boolean
hasEnded()
Returns whether this Span has already been ended.SpanData
toSpanData()
This converts this instance into an immutable SpanData instance, for use in export.
-
-
-
Method Detail
-
getSpanContext
SpanContext getSpanContext()
- Returns:
- the
SpanContext
of theSpan
.
-
getParentSpanContext
SpanContext getParentSpanContext()
- Returns:
- the parent
SpanContext
of theSpan
-
getName
java.lang.String getName()
Returns the name of theSpan
.The name can be changed during the lifetime of the Span by using the
Span.updateName(String)
so this value cannot be cached.Note: the implementation of this method performs locking to ensure thread-safe behavior.
- Returns:
- the name of the
Span
.
-
toSpanData
SpanData toSpanData()
This converts this instance into an immutable SpanData instance, for use in export.- Returns:
- an immutable
SpanData
instance.
-
getInstrumentationLibraryInfo
@Deprecated InstrumentationLibraryInfo getInstrumentationLibraryInfo()
Deprecated.Returns the instrumentation library specified when creating the tracer which produced this span.- Returns:
- an instance of
InstrumentationLibraryInfo
describing the instrumentation library
-
getInstrumentationScopeInfo
default InstrumentationScopeInfo getInstrumentationScopeInfo()
Returns the instrumentation scope specified when creating the tracer which produced this span.- Returns:
- an instance of
InstrumentationScopeInfo
describing the instrumentation scope
-
hasEnded
boolean hasEnded()
Returns whether this Span has already been ended.Note: the implementation of this method performs locking to ensure thread-safe behavior.
- Returns:
true
if the span has already been ended,false
if not.
-
getLatencyNanos
long getLatencyNanos()
Returns the latency of theSpan
in nanos. If still active then returns now() - start time.Note: the implementation of this method performs locking to ensure thread-safe behavior.
- Returns:
- the latency of the
Span
in nanos.
-
getKind
SpanKind getKind()
Returns the kind of the span.- Returns:
- the kind of the span.
-
getAttribute
@Nullable <T> T getAttribute(AttributeKey<T> key)
Returns the value for the givenAttributeKey
, ornull
if not found.The attribute values can be changed during the lifetime of the Span by using
Span.setAttribute(java.lang.String, java.lang.String)
} so this value cannot be cached.Note: the implementation of this method performs locking to ensure thread-safe behavior.
- Returns:
- the value for the given
AttributeKey
, ornull
if not found.
-
getAttributes
default Attributes getAttributes()
Returns the Span attributes.Attributes can be changed during the lifetime of the Span by using
Span.setAttribute(java.lang.String, java.lang.String)
} so this value cannot be cached.Note: the implementation of this method performs locking and returns an immutable copy to ensure thread-safe behavior. If you only need a single attribute it is better to call
getAttribute(AttributeKey)
.- Returns:
- the Span attributes, or
Attributes.empty()
if the span has no attributes. - Since:
- 1.38.0
-
-