Class OpenTelemetrySpanFactory

java.lang.Object
org.axonframework.tracing.opentelemetry.OpenTelemetrySpanFactory
All Implemented Interfaces:
org.axonframework.tracing.SpanFactory

public class OpenTelemetrySpanFactory extends Object implements org.axonframework.tracing.SpanFactory
Creates Span implementations that are compatible with OpenTelemetry java agent instrumentation. OpenTelemetry is a standard to collect logging, tracing and metrics from applications. This SpanFactory focuses on supporting the tracing part of the standard.

To get started with OpenTelemetry, check out their documentation. Note that, even after configuring the correct dependencies, you still need to run the application using the OpenTelemetry java agent to export data. Without this, it will have the same effect as the NoOpSpanFactory since the data is not sent anywhere.

When creating a trace, the context of the current trace is used as a parent, instead of the one active at the time of starting the span (Default OpenTelemetry behavior). This is done using SpanBuilder.setParent(Context).

Since:
4.6.0
Author:
Mitchell Herrijgers
  • Constructor Details

  • Method Details

    • builder

      public static OpenTelemetrySpanFactory.Builder builder()
      Instantiate a Builder to create a OpenTelemetrySpanFactory.

      The SpanAttributeProvieders are defaulted to an empty list, and the Tracer is defaulted to the tracer defined by GlobalOpenTelemetry.

      Returns:
      a Builder able to create a OpenTelemetrySpanFactory.
    • propagateContext

      public <M extends org.axonframework.messaging.Message<?>> M propagateContext(M message)
      Specified by:
      propagateContext in interface org.axonframework.tracing.SpanFactory
    • createRootTrace

      public org.axonframework.tracing.Span createRootTrace(Supplier<String> operationNameSupplier)
      Specified by:
      createRootTrace in interface org.axonframework.tracing.SpanFactory
    • createHandlerSpan

      public org.axonframework.tracing.Span createHandlerSpan(Supplier<String> operationNameSupplier, org.axonframework.messaging.Message<?> parentMessage, boolean isChildTrace, org.axonframework.messaging.Message<?>... linkedParents)
      Specified by:
      createHandlerSpan in interface org.axonframework.tracing.SpanFactory
    • createDispatchSpan

      public org.axonframework.tracing.Span createDispatchSpan(Supplier<String> operationNameSupplier, org.axonframework.messaging.Message<?> parentMessage, org.axonframework.messaging.Message<?>... linkedSiblings)
      Specified by:
      createDispatchSpan in interface org.axonframework.tracing.SpanFactory
    • createInternalSpan

      public org.axonframework.tracing.Span createInternalSpan(Supplier<String> operationNameSupplier)
      Specified by:
      createInternalSpan in interface org.axonframework.tracing.SpanFactory
    • createInternalSpan

      public org.axonframework.tracing.Span createInternalSpan(Supplier<String> operationNameSupplier, org.axonframework.messaging.Message<?> message)
      Specified by:
      createInternalSpan in interface org.axonframework.tracing.SpanFactory
    • registerSpanAttributeProvider

      public void registerSpanAttributeProvider(org.axonframework.tracing.SpanAttributesProvider provider)
      Specified by:
      registerSpanAttributeProvider in interface org.axonframework.tracing.SpanFactory