public interface Span
Tracing span. A span is started by
Span.Builder.start() and ended by either
end() or end(Throwable).
You can obtain SpanContext from context().
Span is the base reporting unit of tracing. Spans can have a parent (Span.Builder.parent(SpanContext),
you can add tag(Tag) to it, and you can log addEvent(String, java.util.Map).-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceSpan.Builder<B extends Span.Builder<B>>Fluent API builder to create a newSpan.static enumSpan kind.static enumSpan status. -
Method Summary
Modifier and TypeMethodDescriptionactivate()Make this span the current active span.default voidAdd a new event to this span.voidAdd an event to this span.Get Baggage Item by key.Sets a baggage item in the Span (and its SpanContext) as a key/value pair.context()Span context can be used to configure a span parent, as is used when a span reference is needed, without the possibility to end such a span.current()Provide current span if one is available.voidend()End this tag (finish processing) using current timestamp.voidEnd with error status and an exception.voidstatus(Span.Status status) Span status, mostly used to configureSpan.Status.ERROR.default SpanAdd a tag to this span.Add a boolean tag.Add a numeric tag.Add a string tag.default <T> TAccess the underlying span by specific type.
-
Method Details
-
current
Provide current span if one is available. This is using a thread local, so it may provide unexpected results in a reactive environment. Please use request methods to obtain request span in Reactive Web Server.- Returns:
- current span or empty optional if there is no current span
- See Also:
-
tag
Add a tag to this span.- Parameters:
tag- tag to add- Returns:
- current span
-
tag
Add a string tag.- Parameters:
key- tag keyvalue- tag value- Returns:
- current span
-
tag
Add a boolean tag.- Parameters:
key- tag keyvalue- tag value- Returns:
- current span
-
tag
Add a numeric tag.- Parameters:
key- tag keyvalue- tag value- Returns:
- current span
-
status
Span status, mostly used to configureSpan.Status.ERROR.- Parameters:
status- status to set
-
context
SpanContext context()Span context can be used to configure a span parent, as is used when a span reference is needed, without the possibility to end such a span.- Returns:
- context of this span
-
addEvent
Add an event to this span.- Parameters:
name- name of the eventattributes- event attributes to be recorded
-
end
void end()End this tag (finish processing) using current timestamp. -
end
End with error status and an exception. Configures status toSpan.Status.ERROR, and adds appropriate tags and events to report this exception.- Parameters:
t- throwable that caused the error status
-
activate
Scope activate()Make this span the current active span. This is expected to use thread locals and as such is not suitable for reactive environment.- Returns:
- current scope
-
baggage
Sets a baggage item in the Span (and its SpanContext) as a key/value pair.- Parameters:
key- String Keyvalue- String Value- Returns:
- current Span instance
-
baggage
Get Baggage Item by key.- Parameters:
key- String key- Returns:
Optionalof the value of the baggage item
-
addEvent
Add a new event to this span.- Parameters:
logMessage- message to log
-
unwrap
Access the underlying span by specific type. This is a dangerous operation that will succeed only if the span is of expected type. This practically removes abstraction capabilities of this API.- Type Parameters:
T- type of the span- Parameters:
spanClass- type to access- Returns:
- instance of the span
- Throws:
IllegalArgumentException- in case the span cannot provide the expected type
-