Interface ExtendedSpanBuilder
- All Superinterfaces:
io.opentelemetry.api.trace.SpanBuilder
SpanBuilder with experimental APIs.-
Method Summary
Modifier and TypeMethodDescriptionaddLink(io.opentelemetry.api.trace.SpanContext spanContext) addLink(io.opentelemetry.api.trace.SpanContext spanContext, io.opentelemetry.api.common.Attributes attributes) default ExtendedSpanBuildersetAllAttributes(io.opentelemetry.api.common.Attributes attributes) setAttribute(io.opentelemetry.api.common.AttributeKey<T> key, T value) setAttribute(String key, boolean value) setAttribute(String key, double value) setAttribute(String key, long value) setAttribute(String key, String value) setParent(io.opentelemetry.context.Context context) setParentFrom(io.opentelemetry.context.propagation.ContextPropagators propagators, Map<String, String> carrier) Extract a span context from the given carrier and set it as parent of the span forstartAndCall(SpanCallable)andstartAndRun(SpanRunnable).setSpanKind(io.opentelemetry.api.trace.SpanKind spanKind) setStartTimestamp(long startTimestamp, TimeUnit unit) default ExtendedSpanBuildersetStartTimestamp(Instant startTimestamp) <T,E extends Throwable>
TstartAndCall(SpanCallable<T, E> spanCallable) Runs the givenSpanCallableinside of the span created by the givenSpanBuilder.<T,E extends Throwable>
TstartAndCall(SpanCallable<T, E> spanCallable, BiConsumer<io.opentelemetry.api.trace.Span, Throwable> handleException) Runs the givenSpanCallableinside of the span created by the givenSpanBuilder.<E extends Throwable>
voidstartAndRun(SpanRunnable<E> runnable) Runs the givenSpanRunnableinside of the span created by the givenSpanBuilder.<E extends Throwable>
voidstartAndRun(SpanRunnable<E> runnable, BiConsumer<io.opentelemetry.api.trace.Span, Throwable> handleException) Runs the givenSpanRunnableinside of the span created by the givenSpanBuilder.Methods inherited from interface io.opentelemetry.api.trace.SpanBuilder
setAttribute, startSpan
-
Method Details
-
setParentFrom
ExtendedSpanBuilder setParentFrom(io.opentelemetry.context.propagation.ContextPropagators propagators, Map<String, String> carrier) Extract a span context from the given carrier and set it as parent of the span forstartAndCall(SpanCallable)andstartAndRun(SpanRunnable).The span context will be extracted from the
carrier, which you usually get from HTTP headers of the metadata of a message you're processing.- Parameters:
propagators- provide the propagators fromOpenTelemetry.getPropagators()carrier- the string map where to extract the span context from
-
startAndCall
Runs the givenSpanCallableinside of the span created by the givenSpanBuilder. The span will be ended at the end of theSpanCallable.If an exception is thrown by the
SpanCallable, the span will be marked as error, and the exception will be recorded.- Type Parameters:
T- the type of the resultE- the type of the exception- Parameters:
spanCallable- theSpanCallableto call- Returns:
- the result of the
SpanCallable - Throws:
E
-
startAndCall
<T,E extends Throwable> T startAndCall(SpanCallable<T, E> spanCallable, BiConsumer<io.opentelemetry.api.trace.Span, throws EThrowable> handleException) Runs the givenSpanCallableinside of the span created by the givenSpanBuilder. The span will be ended at the end of theSpanCallable.If an exception is thrown by the
SpanCallable, thehandleExceptionconsumer will be called, giving you the opportunity to handle the exception and span in a custom way, e.g. not marking the span as error.- Type Parameters:
T- the type of the resultE- the type of the exception- Parameters:
spanCallable- theSpanCallableto callhandleException- the consumer to call when an exception is thrown- Returns:
- the result of the
SpanCallable - Throws:
E
-
startAndRun
Runs the givenSpanRunnableinside of the span created by the givenSpanBuilder. The span will be ended at the end of theSpanRunnable.If an exception is thrown by the
SpanRunnable, the span will be marked as error, and the exception will be recorded.- Type Parameters:
E- the type of the exception- Parameters:
runnable- theSpanRunnableto run- Throws:
E
-
startAndRun
<E extends Throwable> void startAndRun(SpanRunnable<E> runnable, BiConsumer<io.opentelemetry.api.trace.Span, Throwable> handleException) throws ERuns the givenSpanRunnableinside of the span created by the givenSpanBuilder. The span will be ended at the end of theSpanRunnable.If an exception is thrown by the
SpanRunnable, thehandleExceptionconsumer will be called, giving you the opportunity to handle the exception and span in a custom way, e.g. not marking the span as error.- Type Parameters:
E- the type of the exception- Parameters:
runnable- theSpanRunnableto run- Throws:
E
-
setParent
- Specified by:
setParentin interfaceio.opentelemetry.api.trace.SpanBuilder
-
setNoParent
ExtendedSpanBuilder setNoParent()- Specified by:
setNoParentin interfaceio.opentelemetry.api.trace.SpanBuilder
-
addLink
- Specified by:
addLinkin interfaceio.opentelemetry.api.trace.SpanBuilder
-
addLink
ExtendedSpanBuilder addLink(io.opentelemetry.api.trace.SpanContext spanContext, io.opentelemetry.api.common.Attributes attributes) - Specified by:
addLinkin interfaceio.opentelemetry.api.trace.SpanBuilder
-
setAttribute
- Specified by:
setAttributein interfaceio.opentelemetry.api.trace.SpanBuilder
-
setAttribute
- Specified by:
setAttributein interfaceio.opentelemetry.api.trace.SpanBuilder
-
setAttribute
- Specified by:
setAttributein interfaceio.opentelemetry.api.trace.SpanBuilder
-
setAttribute
- Specified by:
setAttributein interfaceio.opentelemetry.api.trace.SpanBuilder
-
setAttribute
- Specified by:
setAttributein interfaceio.opentelemetry.api.trace.SpanBuilder
-
setAllAttributes
- Specified by:
setAllAttributesin interfaceio.opentelemetry.api.trace.SpanBuilder
-
setSpanKind
- Specified by:
setSpanKindin interfaceio.opentelemetry.api.trace.SpanBuilder
-
setStartTimestamp
- Specified by:
setStartTimestampin interfaceio.opentelemetry.api.trace.SpanBuilder
-
setStartTimestamp
- Specified by:
setStartTimestampin interfaceio.opentelemetry.api.trace.SpanBuilder
-