Record Class MessagingTracingSettings

java.lang.Object
java.lang.Record
org.axonframework.messaging.tracing.configuration.MessagingTracingSettings
Record Components:
commandBusEnabled - whether the CommandBus is decorated with tracing
eventSinkEnabled - whether the EventSink is decorated with tracing
eventProcessorEnabled - whether event-handling components (event processors) are decorated with tracing
eventProcessorBatchTraceEnabled - whether streaming-processor batches get an enclosing batch span; when disabled, each event handler span becomes a trace root of its own
eventProcessorDistributedInSameTrace - when true, a handler span continues the publisher's trace; when false (default), it is parented to the streaming batch and links back to the publisher, or starts a linked trace if batch tracing is disabled
eventProcessorDistributedInSameTraceTimeLimit - how recent an event must be to continue the publisher's trace when distributedInSameTrace is true; older events (e.g. replays) start their own trace linked back to the publisher (default PT2M)
queryBusEnabled - whether the QueryBus is decorated with tracing
eventSourcingHandlersEnabled - when true, @EventSourcingHandler invocations get their own per-method span; defaults to false because event sourcing handlers fire once per event during entity replay and would flood traces
spanAttributesProviders - toggles for the built-in span attribute providers contributed by this module

public record MessagingTracingSettings(boolean commandBusEnabled, boolean eventSinkEnabled, boolean eventProcessorEnabled, boolean eventProcessorBatchTraceEnabled, boolean eventProcessorDistributedInSameTrace, Duration eventProcessorDistributedInSameTraceTimeLimit, boolean queryBusEnabled, boolean eventSourcingHandlersEnabled, MessagingTracingSettings.SpanAttributesProviders spanAttributesProviders) extends Record
Per-component on/off toggles for messaging tracing, read by MessagingTracingConfigurationEnhancer to decide which axon-messaging components to decorate.

When no instance is registered, every component defaults to enabled (enabledByDefault()). To adjust the toggles declaratively, register an instance as a component -- typically starting from the defaults and using the with* copy methods:


 configurer.componentRegistry(cr -> cr.registerComponent(
         MessagingTracingSettings.class,
         c -> MessagingTracingSettings.enabledByDefault().withEventProcessorDistributedInSameTrace(true)));
 
Higher-level integrations (for example property-based configuration layers) register a translated instance on the application's behalf; an explicitly registered component always takes precedence.
Since:
5.3.0
Author:
Mateusz Nowak
  • Field Details

    • DEFAULT_DISTRIBUTED_IN_SAME_TRACE_TIME_LIMIT

      public static final Duration DEFAULT_DISTRIBUTED_IN_SAME_TRACE_TIME_LIMIT
      Default time limit for distributedInSameTrace.
  • Constructor Details

  • Method Details

    • enabledByDefault

      public static MessagingTracingSettings enabledByDefault()
      Returns the default settings, with every messaging component enabled for tracing and default values for the event-processor sub-toggles (batchTraceEnabled=true, distributedInSameTrace=false, distributedInSameTraceTimeLimit=PT2M) and the handler enhancer (eventSourcingHandlersEnabled=false -- replay-noisy event sourcing handlers are not traced). Every built-in span attribute provider is enabled.
      Returns:
      the all-enabled default settings
    • withCommandBusEnabled

      public MessagingTracingSettings withCommandBusEnabled(boolean commandBusEnabled)
      Returns a copy of these settings with commandBusEnabled() replaced by the given value.
      Parameters:
      commandBusEnabled - whether the CommandBus is decorated with tracing
      Returns:
      a copy of these settings with the given commandBusEnabled
    • withEventSinkEnabled

      public MessagingTracingSettings withEventSinkEnabled(boolean eventSinkEnabled)
      Returns a copy of these settings with eventSinkEnabled() replaced by the given value.
      Parameters:
      eventSinkEnabled - whether the EventSink is decorated with tracing
      Returns:
      a copy of these settings with the given eventSinkEnabled
    • withEventProcessorEnabled

      public MessagingTracingSettings withEventProcessorEnabled(boolean eventProcessorEnabled)
      Returns a copy of these settings with eventProcessorEnabled() replaced by the given value.
      Parameters:
      eventProcessorEnabled - whether event-handling components (event processors) are decorated with tracing
      Returns:
      a copy of these settings with the given eventProcessorEnabled
    • withEventProcessorBatchTraceEnabled

      public MessagingTracingSettings withEventProcessorBatchTraceEnabled(boolean eventProcessorBatchTraceEnabled)
      Returns a copy of these settings with eventProcessorBatchTraceEnabled() replaced by the given value.
      Parameters:
      eventProcessorBatchTraceEnabled - whether streaming-processor batches get an enclosing batch span
      Returns:
      a copy of these settings with the given eventProcessorBatchTraceEnabled
    • withEventProcessorDistributedInSameTrace

      public MessagingTracingSettings withEventProcessorDistributedInSameTrace(boolean eventProcessorDistributedInSameTrace)
      Returns a copy of these settings with eventProcessorDistributedInSameTrace() replaced by the given value.
      Parameters:
      eventProcessorDistributedInSameTrace - when true, a handler span continues the publisher's trace
      Returns:
      a copy of these settings with the given eventProcessorDistributedInSameTrace
    • withEventProcessorDistributedInSameTraceTimeLimit

      public MessagingTracingSettings withEventProcessorDistributedInSameTraceTimeLimit(Duration eventProcessorDistributedInSameTraceTimeLimit)
      Returns a copy of these settings with eventProcessorDistributedInSameTraceTimeLimit() replaced by the given value.
      Parameters:
      eventProcessorDistributedInSameTraceTimeLimit - how recent an event must be to continue the publisher's trace when distributedInSameTrace is true
      Returns:
      a copy of these settings with the given eventProcessorDistributedInSameTraceTimeLimit
    • withQueryBusEnabled

      public MessagingTracingSettings withQueryBusEnabled(boolean queryBusEnabled)
      Returns a copy of these settings with queryBusEnabled() replaced by the given value.
      Parameters:
      queryBusEnabled - whether the QueryBus is decorated with tracing
      Returns:
      a copy of these settings with the given queryBusEnabled
    • withEventSourcingHandlersEnabled

      public MessagingTracingSettings withEventSourcingHandlersEnabled(boolean eventSourcingHandlersEnabled)
      Returns a copy of these settings with eventSourcingHandlersEnabled() replaced by the given value.
      Parameters:
      eventSourcingHandlersEnabled - whether @EventSourcingHandler invocations get their own span
      Returns:
      a copy of these settings with the given eventSourcingHandlersEnabled
    • withSpanAttributesProviders

      public MessagingTracingSettings withSpanAttributesProviders(MessagingTracingSettings.SpanAttributesProviders spanAttributesProviders)
      Returns a copy of these settings with spanAttributesProviders() replaced by the given value.
      Parameters:
      spanAttributesProviders - toggles for the built-in span attribute providers contributed by this module
      Returns:
      a copy of these settings with the given spanAttributesProviders
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • commandBusEnabled

      public boolean commandBusEnabled()
      Returns the value of the commandBusEnabled record component.
      Returns:
      the value of the commandBusEnabled record component
    • eventSinkEnabled

      public boolean eventSinkEnabled()
      Returns the value of the eventSinkEnabled record component.
      Returns:
      the value of the eventSinkEnabled record component
    • eventProcessorEnabled

      public boolean eventProcessorEnabled()
      Returns the value of the eventProcessorEnabled record component.
      Returns:
      the value of the eventProcessorEnabled record component
    • eventProcessorBatchTraceEnabled

      public boolean eventProcessorBatchTraceEnabled()
      Returns the value of the eventProcessorBatchTraceEnabled record component.
      Returns:
      the value of the eventProcessorBatchTraceEnabled record component
    • eventProcessorDistributedInSameTrace

      public boolean eventProcessorDistributedInSameTrace()
      Returns the value of the eventProcessorDistributedInSameTrace record component.
      Returns:
      the value of the eventProcessorDistributedInSameTrace record component
    • eventProcessorDistributedInSameTraceTimeLimit

      public Duration eventProcessorDistributedInSameTraceTimeLimit()
      Returns the value of the eventProcessorDistributedInSameTraceTimeLimit record component.
      Returns:
      the value of the eventProcessorDistributedInSameTraceTimeLimit record component
    • queryBusEnabled

      public boolean queryBusEnabled()
      Returns the value of the queryBusEnabled record component.
      Returns:
      the value of the queryBusEnabled record component
    • eventSourcingHandlersEnabled

      public boolean eventSourcingHandlersEnabled()
      Returns the value of the eventSourcingHandlersEnabled record component.
      Returns:
      the value of the eventSourcingHandlersEnabled record component
    • spanAttributesProviders

      public MessagingTracingSettings.SpanAttributesProviders spanAttributesProviders()
      Returns the value of the spanAttributesProviders record component.
      Returns:
      the value of the spanAttributesProviders record component