Class MicrometerTracingConfigurationEnhancer

java.lang.Object
io.axoniq.framework.tracing.micrometer.MicrometerTracingConfigurationEnhancer
All Implemented Interfaces:
ConfigurationEnhancer

@RegistrationScope("Register the SpanFactory and context-propagation registries once at the root; the registrations are idempotent and need not be repeated in child module registries.") public final class MicrometerTracingConfigurationEnhancer extends Object implements ConfigurationEnhancer
ConfigurationEnhancer that enables Micrometer-Tracing-backed tracing. Discovered automatically via ServiceLoader, so having the axoniq-tracing-micrometer module on the classpath is enough; there is no need to register it manually.

It registers a MicrometerSpanFactory as the SpanFactory component and installs the ProcessingContextAccessor (the reactive bridge that exposes the active Axon span from a ProcessingContext to Micrometer's context propagation).

Bridge-specific components (host-supplied). This enhancer resolves the Micrometer abstractions as framework components rather than creating them, because they are provided by a concrete Micrometer tracing bridge (for example micrometer-tracing-bridge-otel), not by this module:

  • Tracer and Propagator -- required to enable tracing. When either is absent, this enhancer backs off entirely (an INFO log explains how to enable tracing) and no SpanFactory is registered -- matching the framework contract that tracing is off when no SpanFactory component exists. The jar being on the classpath (possibly transitively) therefore never breaks a configuration that does not wire a Micrometer bridge.
  • ObservationRegistry -- optional; defaulted to ObservationRegistry.create() when absent.
The host application registers the Tracer and Propagator as components, obtained from its chosen bridge, e.g.:

 configurer.componentRegistry(registry -> registry
         .registerComponent(Tracer.class, c -> tracer)
         .registerComponent(Propagator.class, c -> propagator));
 

The ContextRegistry is registered as a component (defaulting to ContextRegistry.getInstance()), used as the source for the ContextSnapshotFactory of the thread-local bridge. The ProcessingContextAccessor is registered onto that component via a decorator (not onto the global singleton directly), so it honours a user-registered ContextRegistry. The in-process thread-local bridge itself lives in the threadlocal sibling package and is installed by a separate, independently toggleable enhancer.

Since:
5.3.0
Author:
Mateusz Nowak
  • Constructor Details

    • MicrometerTracingConfigurationEnhancer

      public MicrometerTracingConfigurationEnhancer()
  • Method Details

    • enhance

      public void enhance(ComponentRegistry registry)
      Description copied from interface: ConfigurationEnhancer
      Enhances the given registry with, for example, additional components and decorators.
      Specified by:
      enhance in interface ConfigurationEnhancer
      Parameters:
      registry - The registry instance to enhance.
    • order

      public int order()
      Description copied from interface: ConfigurationEnhancer
      Returns the relative order this enhancer should be invoked in, compared to other instances.

      Use lower (negative) values for enhancers providing sensible defaults, and higher values for enhancers that should be able to override values potentially previously set. Defaults to 0 when not set.

      Specified by:
      order in interface ConfigurationEnhancer
      Returns:
      The order in which this enhancer should be invoked.