Package io.micrometer.tracing
Interface Span.Builder
- Enclosing interface:
Span
public static interface Span.Builder
In some cases (e.g. when dealing with
Propagator.extract(Object, Propagator.Getter)
's we want to create a span
that has not yet been started, yet it's heavily configurable (some options are not
possible to be set when a span has already been started). We can achieve that by
using a builder.
Inspired by OpenZipkin Brave and OpenTelemetry API.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionSets an error on the span.Sets an event on the span.Sets the kind on the span.Sets the name of the span.remoteIpAndPort
(String ip, int port) Sets the remote URL for the span.remoteServiceName
(String remoteServiceName) Sets the remote service name for the span.Sets no parent of the built span.setParent
(TraceContext context) Sets the parent of the built span.start()
Builds and starts the span.startTimestamp
(long startTimestamp, TimeUnit unit) Sets start timestamp.Sets a tag on the span.
-
Field Details
-
NOOP
A noop implementation.
-
-
Method Details
-
setParent
Sets the parent of the built span.- Parameters:
context
- parent's context- Returns:
- this
-
setNoParent
Span.Builder setNoParent()Sets no parent of the built span.- Returns:
- this
-
name
Sets the name of the span.- Parameters:
name
- span name- Returns:
- this
-
event
Sets an event on the span.- Parameters:
value
- event value- Returns:
- this
-
tag
Sets a tag on the span.- Parameters:
key
- tag keyvalue
- tag value- Returns:
- this
-
error
Sets an error on the span.- Parameters:
throwable
- error to set- Returns:
- this
-
kind
Sets the kind on the span.- Parameters:
spanKind
- kind of the span- Returns:
- this
-
remoteServiceName
Sets the remote service name for the span.- Parameters:
remoteServiceName
- remote service name- Returns:
- this
-
remoteIpAndPort
Sets the remote URL for the span.- Parameters:
ip
- remote service ipport
- remote service port- Returns:
- this
-
startTimestamp
Sets start timestamp.- Parameters:
startTimestamp
- start timestampunit
- start time unit- Returns:
- this
-
start
Span start()Builds and starts the span.- Returns:
- started span
-