public class OpenTelemetrySpan extends Object implements Span
Span
implementation that uses OpenTelemetry's Span
to provide tracing
capabilities to an application.
These traces should always be created using the OpenTelemetrySpanFactory
since this will make sure the proper
parent context is extracted before creating the Span
.
Each start()
should result in an end()
being called. Only when the last end()
is called
will the OpenTelemetry span actually be ended. This is because Scope
s that are kept active should be closed
before ending the span, or memory leaks can occur. This is also the reason the scopes
are kept in a
Deque
.
Constructor and Description |
---|
OpenTelemetrySpan(io.opentelemetry.api.trace.SpanBuilder spanBuilder)
Creates the span, based on the
SpanBuilder provided. |
Modifier and Type | Method and Description |
---|---|
void |
end()
Ends the span.
|
Span |
recordException(Throwable t)
Records an exception to the span.
|
Span |
start()
Starts the Span.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
run, runCallable, runSupplier, wrapCallable, wrapRunnable, wrapSupplier
public OpenTelemetrySpan(io.opentelemetry.api.trace.SpanBuilder spanBuilder)
SpanBuilder
provided. This SpanBuilder
will supply the
Span
when the start()
method is invoked.spanBuilder
- The provider of the Span
.public Span start()
Span
public void end()
Span
public Span recordException(Throwable t)
Span
recordException
in interface Span
t
- The exception to recordCopyright © 2010–2023. All rights reserved.