Class Span
- Direct Known Subclasses:
BlankSpan
,NoRecordEventsSpanImpl
,RecordEventsSpanImpl
SpanContext
and a set of
Span.Options
.
Spans are created by the SpanBuilder.startSpan()
method.
Span
must be ended by calling end()
or end(EndSpanOptions)
- Since:
- 0.5
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Type of span.static enum
Span
options. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final SpanContext
private static final Set
<Span.Options> private static final Map
<String, AttributeValue> private final Set
<Span.Options> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Span
(SpanContext context, EnumSet<Span.Options> options) Creates a newSpan
. -
Method Summary
Modifier and TypeMethodDescriptionabstract void
addAnnotation
(Annotation annotation) Adds an annotation to theSpan
.final void
addAnnotation
(String description) Adds an annotation to theSpan
.abstract void
addAnnotation
(String description, Map<String, AttributeValue> attributes) Adds an annotation to theSpan
.void
addAttributes
(Map<String, AttributeValue> attributes) Deprecated.abstract void
Adds aLink
to theSpan
.void
addMessageEvent
(MessageEvent messageEvent) Adds a MessageEvent to theSpan
.void
addNetworkEvent
(NetworkEvent networkEvent) Deprecated.final void
end()
Marks the end ofSpan
execution with the default options.abstract void
end
(EndSpanOptions options) Marks the end ofSpan
execution with the given options.final SpanContext
Returns theSpanContext
associated with thisSpan
.final Set
<Span.Options> Returns the options associated with thisSpan
.void
putAttribute
(String key, AttributeValue value) Sets an attribute to theSpan
.void
putAttributes
(Map<String, AttributeValue> attributes) Sets a set of attributes to theSpan
.void
Sets theStatus
to theSpan
.
-
Field Details
-
EMPTY_ATTRIBUTES
-
context
-
options
-
DEFAULT_OPTIONS
-
-
Constructor Details
-
Span
Creates a newSpan
.- Parameters:
context
- the context associated with thisSpan
.options
- the options associated with thisSpan
. Ifnull
then default options will be set.- Throws:
NullPointerException
- if context isnull
.IllegalArgumentException
- if theSpanContext
is sampled but no RECORD_EVENTS options.- Since:
- 0.5
-
-
Method Details
-
putAttribute
Sets an attribute to theSpan
. If theSpan
previously contained a mapping for the key, the old value is replaced by the specified value.- Parameters:
key
- the key for this attribute.value
- the value for this attribute.- Since:
- 0.6
-
putAttributes
Sets a set of attributes to theSpan
. The effect of this call is equivalent to that of callingputAttribute(String, AttributeValue)
once for each element in the specified map.- Parameters:
attributes
- the attributes that will be added and associated with theSpan
.- Since:
- 0.6
-
addAttributes
Deprecated.Sets a set of attributes to theSpan
. The effect of this call is equivalent to that of callingputAttribute(String, AttributeValue)
once for each element in the specified map.- Parameters:
attributes
- the attributes that will be added and associated with theSpan
.- Since:
- 0.5
-
addAnnotation
Adds an annotation to theSpan
.- Parameters:
description
- the description of the annotation time event.- Since:
- 0.5
-
addAnnotation
Adds an annotation to theSpan
.- Parameters:
description
- the description of the annotation time event.attributes
- the attributes that will be added; these are associated with this annotation, not theSpan
as forputAttributes(Map)
.- Since:
- 0.5
-
addAnnotation
Adds an annotation to theSpan
.- Parameters:
annotation
- the annotations to add.- Since:
- 0.5
-
addNetworkEvent
Deprecated.Adds a NetworkEvent to theSpan
.This function is only intended to be used by RPC systems (either client or server), not by higher level applications.
- Parameters:
networkEvent
- the network event to add.- Since:
- 0.5
-
addMessageEvent
Adds a MessageEvent to theSpan
.This function can be used by higher level applications to record messaging event.
This method should always be overridden by users whose API versions are larger or equal to
0.12
.- Parameters:
messageEvent
- the message to add.- Since:
- 0.12
-
addLink
Adds aLink
to theSpan
.Used (for example) in batching operations, where a single batch handler processes multiple requests from different traces.
- Parameters:
link
- the link to add.- Since:
- 0.5
-
setStatus
Sets theStatus
to theSpan
.If used, this will override the default
Span
status. Default isStatus.OK
.Only the value of the last call will be recorded, and implementations are free to ignore previous calls. If the status is set via
EndSpanOptions.Builder.setStatus(Status)
that will always be the last call.- Parameters:
status
- theStatus
to set.- Since:
- 0.9
-
end
Marks the end ofSpan
execution with the given options.Only the timing of the first end call for a given
Span
will be recorded, and implementations are free to ignore all further calls.- Parameters:
options
- the options to be used for the end of theSpan
.- Since:
- 0.5
-
end
public final void end()Marks the end ofSpan
execution with the default options.Only the timing of the first end call for a given
Span
will be recorded, and implementations are free to ignore all further calls.- Since:
- 0.5
-
getContext
Returns theSpanContext
associated with thisSpan
.- Returns:
- the
SpanContext
associated with thisSpan
. - Since:
- 0.5
-
getOptions
Returns the options associated with thisSpan
.- Returns:
- the options associated with this
Span
. - Since:
- 0.5
-
putAttributes(Map)