@ThreadSafe public interface Span
SpanContext.
Spans are created by the Span.Builder.startSpan() method.
Span must be ended by calling end().
| Modifier and Type | Interface and Description |
|---|---|
static interface |
Span.Builder
Span.Builder is used to construct Span instances which define arbitrary scopes of
code that are sampled for distributed tracing as a single atomic unit. |
static class |
Span.Kind
Type of span.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addEvent(Event event)
Adds an event to the
Span. |
void |
addEvent(Event event,
long timestamp)
Adds an event to the
Span. |
void |
addEvent(String name)
Adds an event to the
Span. |
void |
addEvent(String name,
Attributes attributes)
Adds an event to the
Span. |
void |
addEvent(String name,
Attributes attributes,
long timestamp)
Adds an event to the
Span. |
void |
addEvent(String name,
long timestamp)
Adds an event to the
Span. |
void |
end()
Marks the end of
Span execution. |
void |
end(EndSpanOptions endOptions)
Marks the end of
Span execution with the specified EndSpanOptions. |
SpanContext |
getContext()
Returns the
SpanContext associated with this Span. |
boolean |
isRecording()
Returns
true if this Span records tracing events (e.g. |
void |
setAttribute(String key,
AttributeValue value)
Sets an attribute to the
Span. |
void |
setAttribute(String key,
boolean value)
Sets an attribute to the
Span. |
void |
setAttribute(String key,
double value)
Sets an attribute to the
Span. |
void |
setAttribute(String key,
long value)
Sets an attribute to the
Span. |
void |
setAttribute(String key,
String value)
Sets an attribute to the
Span. |
void |
setStatus(Status status)
Sets the
Status to the Span. |
void |
updateName(String name)
Updates the
Span name. |
void setAttribute(String key, @Nullable String value)
Span. If the Span 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 attribute will be silently
dropped. Note: this behavior could change in the future.
key - the key for this attribute.value - the value for this attribute.void setAttribute(String key, long value)
Span. If the Span previously contained a mapping for
the key, the old value is replaced by the specified value.key - the key for this attribute.value - the value for this attribute.void setAttribute(String key, double value)
Span. If the Span previously contained a mapping for
the key, the old value is replaced by the specified value.key - the key for this attribute.value - the value for this attribute.void setAttribute(String key, boolean value)
Span. If the Span previously contained a mapping for
the key, the old value is replaced by the specified value.key - the key for this attribute.value - the value for this attribute.void setAttribute(String key, AttributeValue value)
Span. If the Span previously contained a mapping for
the key, the old value is replaced by the specified value.key - the key for this attribute.value - the value for this attribute.void addEvent(String name)
Span.name - the name of the event.void addEvent(String name, long timestamp)
Span.
Use this method to specify an explicit event timestamp. If not called, the implementation will use the current timestamp value, which should be the default case.
Important: this is NOT equivalent with System.nanoTime().
name - the name of the event.timestamp - the explicit event timestamp in nanos since epoch.void addEvent(String name, Attributes attributes)
Span.name - the name of the event.attributes - the attributes that will be added; these are associated with this event, not
the Span as for setAttribute().void addEvent(String name, Attributes attributes, long timestamp)
Span.
Use this method to specify an explicit event timestamp. If not called, the implementation will use the current timestamp value, which should be the default case.
Important: this is NOT equivalent with System.nanoTime().
name - the name of the event.attributes - the attributes that will be added; these are associated with this event, not
the Span as for setAttribute().timestamp - the explicit event timestamp in nanos since epoch.void addEvent(Event event)
Span.event - the event to add.void addEvent(Event event, long timestamp)
Span.
Use this method to specify an explicit event timestamp. If not called, the implementation will use the current timestamp value, which should be the default case.
Important: this is NOT equivalent with System.nanoTime().
event - the event to add.timestamp - the explicit event timestamp in nanos since epoch.void setStatus(Status status)
Status to the Span.
If used, this will override the default Span status. Default is Status.OK.
Only the value of the last call will be recorded, and implementations are free to ignore previous calls.
status - the Status to set.void updateName(String name)
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.
name - the Span name.void end()
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.
void end(EndSpanOptions endOptions)
Span execution with the specified EndSpanOptions.
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().
endOptions - the explicit EndSpanOptions for this Span.SpanContext getContext()
SpanContext associated with this Span.SpanContext associated with this Span.boolean isRecording()
true if this Span records tracing events (e.g. addEvent(String), setAttribute(String, long)).true if this Span records tracing events.