Package org.springframework.cloud.sleuth
Interface Span.Builder
-
- All Known Subinterfaces:
AssertingSpanBuilder
- Enclosing interface:
- Span
public static interface Span.BuilderIn some cases (e.g. when dealing withPropagator.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.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Span.Buildererror(Throwable throwable)Sets an error on the span.Span.Builderevent(String value)Sets an event on the span.Span.Builderkind(Span.Kind spanKind)Sets the kind on the span.Span.Buildername(String name)Sets the name of the span.default Span.BuilderremoteIpAndPort(String ip, int port)Sets the remote URL for the span.Span.BuilderremoteServiceName(String remoteServiceName)Sets the remote service name for the span.Span.BuildersetNoParent()Sets no parent of the built span.Span.BuildersetParent(TraceContext context)Sets the parent of the built span.Spanstart()Builds and starts the span.Span.Buildertag(String key, String value)Sets a tag on the span.
-
-
-
Method Detail
-
setParent
Span.Builder setParent(TraceContext context)
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
Span.Builder name(String name)
Sets the name of the span.- Parameters:
name- span name- Returns:
- this
-
event
Span.Builder event(String value)
Sets an event on the span.- Parameters:
value- event value- Returns:
- this
-
tag
Span.Builder tag(String key, String value)
Sets a tag on the span.- Parameters:
key- tag keyvalue- tag value- Returns:
- this
-
error
Span.Builder error(Throwable throwable)
Sets an error on the span.- Parameters:
throwable- error to set- Returns:
- this
-
kind
Span.Builder kind(Span.Kind spanKind)
Sets the kind on the span.- Parameters:
spanKind- kind of the span- Returns:
- this
-
remoteServiceName
Span.Builder remoteServiceName(String remoteServiceName)
Sets the remote service name for the span.- Parameters:
remoteServiceName- remote service name- Returns:
- this
-
remoteIpAndPort
default Span.Builder remoteIpAndPort(String ip, int port)
Sets the remote URL for the span.- Parameters:
ip- remote service ipport- remote service port- Returns:
- this
-
start
Span start()
Builds and starts the span.- Returns:
- started span
-
-