Class OpenTelemetrySpan
java.lang.Object
org.axonframework.extension.tracing.opentelemetry.OpenTelemetrySpan
- All Implemented Interfaces:
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.
- Since:
- 4.6.0
- Author:
- Mitchell Herrijgers
-
Constructor Summary
ConstructorsConstructorDescriptionOpenTelemetrySpan(io.opentelemetry.api.trace.SpanBuilder spanBuilder) Creates the span, based on theSpanBuilderprovided. -
Method Summary
Modifier and TypeMethodDescriptionaddAttribute(String key, String value) Adds an attribute to the span.voidend()Ends the span.Sets the Span as the current for the current thread.Records an exception to the span.start()Starts the Span.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.axonframework.messaging.tracing.Span
run, runCallable, runConsumer, runSupplier, runSupplierAsync, wrapCallable, wrapConsumer, wrapRunnable, wrapSupplier
-
Constructor Details
-
OpenTelemetrySpan
public OpenTelemetrySpan(io.opentelemetry.api.trace.SpanBuilder spanBuilder) Creates the span, based on theSpanBuilderprovided. ThisSpanBuilderwill supply theSpanwhen thestart()method is invoked.- Parameters:
spanBuilder- The provider of theSpan.
-
-
Method Details
-
start
Description copied from interface:SpanStarts the Span. However, does not set this span as the span of the current thread. SeeSpan.makeCurrent()in order to do so. -
makeCurrent
Description copied from interface:SpanSets the Span as the current for the current thread. The returnedSpanScopemust be closed before ending the Span, on the same thread, or through a try-with-resources statement in the same thread as this method was called.You can make a span current on as many threads as you like, but you have to close every
SpanScope, or context will leak into the current thread. Note that if this is neglected, theSpan.end()method should warn the user in order to report this back to the framework.- Specified by:
makeCurrentin interfaceSpan- Returns:
- The scope of the span that must be closed be
-
end
public void end()Description copied from interface:SpanEnds the span. All scopes should have been closed at this point. In addition, a span can only be ended once.If scopes are still open when this method is called, either an exception should be thrown or an error log should be produced to warn the user of the leak. This information can then be reported back to the developers of the framework for a fix.
-
recordException
Description copied from interface:SpanRecords an exception to the span. This will be reported to the APM tooling, which can show more information about the error in the trace. This method does not end the span.- Specified by:
recordExceptionin interfaceSpan- Parameters:
t- The exception to record- Returns:
- The span for fluent interfacing.
-
addAttribute
Description copied from interface:SpanAdds an attribute to the span. This can be used to add extra information to the span, which can be used by the APM tooling to provide more information about the span.- Specified by:
addAttributein interfaceSpan- Parameters:
key- The key of the attribute.value- The value of the attribute.- Returns:
- The span for fluent interfacing.
-