public abstract class Span extends Object
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)
| Modifier and Type | Class and Description |
|---|---|
static class |
Span.Options
Span options. |
| Modifier | Constructor and Description |
|---|---|
protected |
Span(SpanContext context,
EnumSet<Span.Options> options)
Creates a new
Span. |
| Modifier and Type | Method and Description |
|---|---|
abstract void |
addAnnotation(Annotation annotation)
Adds an annotation to the
Span. |
void |
addAnnotation(String description)
Adds an annotation to the
Span. |
abstract void |
addAnnotation(String description,
Map<String,AttributeValue> attributes)
Adds an annotation to the
Span. |
abstract void |
addAttributes(Map<String,AttributeValue> attributes)
Adds a set of attributes to the
Span. |
abstract void |
addLink(Link link)
Adds a
Link to the Span. |
abstract void |
addNetworkEvent(NetworkEvent networkEvent)
Adds a NetworkEvent to the
Span. |
void |
end()
Marks the end of
Span execution with the default options. |
abstract void |
end(EndSpanOptions options)
Marks the end of
Span execution with the given options. |
SpanContext |
getContext()
Returns the
SpanContext associated with this Span. |
Set<Span.Options> |
getOptions()
Returns the options associated with this
Span. |
protected Span(SpanContext context, @Nullable EnumSet<Span.Options> options)
Span.context - the context associated with this Span.options - the options associated with this Span. If null then default
options will be set.NullPointerException - if context is null.IllegalArgumentException - if the SpanContext is sampled but no RECORD_EVENTS
options.public abstract void addAttributes(Map<String,AttributeValue> attributes)
Span.attributes - the attributes that will be added and associated with the Span.public final void addAnnotation(String description)
Span.description - the description of the annotation time event.public abstract void addAnnotation(String description, Map<String,AttributeValue> attributes)
Span.description - the description of the annotation time event.attributes - the attributes that will be added; these are associated with this annotation,
not the Span as for addAttributes(java.util.Map<java.lang.String, com.google.instrumentation.trace.AttributeValue>).public abstract void addAnnotation(Annotation annotation)
Span.annotation - the annotations to add.public abstract void addNetworkEvent(NetworkEvent networkEvent)
Span.
This function is only intended to be used by RPC systems (either client or server), not by higher level applications.
networkEvent - the network event to add.public abstract void addLink(Link link)
Link to the Span.
Used (for example) in batching operations, where a single batch handler processes multiple requests from different traces.
link - the link to add.public abstract void end(EndSpanOptions options)
Span 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.
options - the options to be used for the end of the Span.public final void end()
Span 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.
public final SpanContext getContext()
SpanContext associated with this Span.SpanContext associated with this Span.public final Set<Span.Options> getOptions()
Span.Span.