Class TracingHandlerEnhancerDefinition

java.lang.Object
org.axonframework.messaging.tracing.annotation.TracingHandlerEnhancerDefinition
All Implemented Interfaces:
HandlerEnhancerDefinition

@Internal public final class TracingHandlerEnhancerDefinition extends Object implements HandlerEnhancerDefinition
HandlerEnhancerDefinition that wraps annotated message handlers in a tracing span named after the handling method (for example "BookRoomHandler.handle(BookRoom)"). Message-type agnostic: every annotated handler kind receives the same enhancement -- the span lifecycle is driven entirely by MessageHandlingMember / ProcessingContext. Each wrapper preserves the original member's marker interface (command, event, or query handling member), so metamodel construction that classifies handlers by marker interface is unaffected by tracing.

Discovered via the standard META-INF/services HandlerEnhancerDefinition ServiceLoader entry shipped with axon-messaging, so no explicit registration is required. The configured SpanFactory is resolved from the ProcessingContext's ApplicationContext at handle time -- when no factory is registered, the wrapper is a pass-through.

@EventSourcingHandler suppression. Members carrying the EventSourcingHandler handler attribute are suppressed by default: they fire once per event during entity replay (a hot path) and would flood traces with one span per replayed event. Suppression is decided before any span name is built or the SpanFactory is resolved, so a suppressed invocation carries no tracing cost beyond a boolean check. Set MessagingTracingSettings.eventSourcingHandlersEnabled() to true to trace them anyway.

Since:
4.6.0
Author:
Mitchell Herrijgers, Mateusz Nowak
  • Constructor Details

    • TracingHandlerEnhancerDefinition

      public TracingHandlerEnhancerDefinition()
  • Method Details