Class NestingSpanFactory
- All Implemented Interfaces:
SpanFactory
SpanFactory that wraps another factory and creates nested spans when handling messages
instead of starting a new trace. This is true for all messages, such as events, commands, deadlines and queries.
For events and deadlines specifically, this factory includes a time limit (by default 2 minutes, but is configurable on the builder). After that time limit, handling these message types will become a separate trace. The time limit prevents handling of events from being added to the original trace after a longer period of time, such as when replaying an event processor.
- Since:
- 4.7.0
- Author:
- Mitchell Herrijgers
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDeprecated.Creates a builder that will create aNestingSpanFactory. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDeprecated.Creates theNestingSpanFactorybased on theNestingSpanFactory.Builderprovided. -
Method Summary
Modifier and TypeMethodDescriptionstatic NestingSpanFactory.Builderbuilder()Deprecated.Creates a newNestingSpanFactory.Builderthat can build aNestingSpanFactory.createDispatchSpan(Supplier<String> operationNameSupplier, Message<?> parentMessage, Message<?>... linkedSiblings) Deprecated.createHandlerSpan(Supplier<String> operationNameSupplier, Message<?> parentMessage, boolean isChildTrace, Message<?>... linkedParents) Deprecated.createInternalSpan(Supplier<String> operationNameSupplier) Deprecated.Creates a newSpanlinked to the currently active span.createInternalSpan(Supplier<String> operationNameSupplier, Message<?> message) Deprecated.Creates a newSpanlinked to the currently active span.createRootTrace(Supplier<String> operationNameSupplier) Deprecated.Creates a newSpanwithout any parent trace.<M extends Message<?>>
MpropagateContext(M message) Deprecated.Propagates the currently active trace and span to the message.voidDeprecated.Registers an additionalSpanAttributesProviderto the factory.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.axonframework.tracing.SpanFactory
createChildHandlerSpan, createLinkedHandlerSpan
-
Constructor Details
-
NestingSpanFactory
Deprecated.Creates theNestingSpanFactorybased on theNestingSpanFactory.Builderprovided.- Parameters:
builder- TheNestingSpanFactory.Builderto use during construction.
-
-
Method Details
-
builder
Deprecated.Creates a newNestingSpanFactory.Builderthat can build aNestingSpanFactory.Requires the delegate
SpanFactoryto be configured.The
Clockdefaults to the system utc time and the timeLimitDurationdefaults to two minutes.- Returns:
- The
NestingSpanFactory.Builderin charge of creating aNestingSpanFactory.
-
createRootTrace
Deprecated.Description copied from interface:SpanFactoryCreates a newSpanwithout any parent trace. This should be used for logical start point of asynchronous calls that are not related to a message. For example snapshotting an aggregate.In monitoring systems, this Span will be the root of the trace.
- Specified by:
createRootTracein interfaceSpanFactory- Parameters:
operationNameSupplier- Supplier of the operation's name.- Returns:
- The created
Span.
-
createHandlerSpan
public Span createHandlerSpan(Supplier<String> operationNameSupplier, Message<?> parentMessage, boolean isChildTrace, Message<?>... linkedParents) Deprecated.Description copied from interface:SpanFactoryCreates a newSpanlinked to asynchronously handling aMessage, for example when handling a command from Axon Server. The message attributes will be added to the span, based on the providedSpanAttributesProvidersfor additional debug information.In monitoring systems, this Span will be the root of the trace.
The message's name will be concatenated with the
operationName, seeSpanUtils.determineMessageName(Message).- Specified by:
createHandlerSpanin interfaceSpanFactory- Parameters:
operationNameSupplier- Supplier of the operation's name.parentMessage- The message that is being handled.isChildTrace- Whether to force the span to be a part of the current trace. This means not linking, but setting a parent.linkedParents- Optional parameter, providing this will link the provided message(s) to the current, in addition to the original.- Returns:
- The created
Span.
-
createDispatchSpan
public Span createDispatchSpan(Supplier<String> operationNameSupplier, Message<?> parentMessage, Message<?>... linkedSiblings) Deprecated.Description copied from interface:SpanFactoryCreates a newSpanlinked to dispatching aMessage, for example when sending a command to Axon Server. The message attributes will be added to the span, based on the providedSpanAttributesProvidersfor additional debug information.In monitoring systems, this Span will be part of another trace.
Before asynchronously dispatching a message, add the tracing context to the message, using
SpanFactory.propagateContext(Message)to the message's metadata.The message's name will be concatenated with the
operationName, seeSpanUtils.determineMessageName(Message).- Specified by:
createDispatchSpanin interfaceSpanFactory- Parameters:
operationNameSupplier- Supplier of the operation's name.parentMessage- The message that is being handled.linkedSiblings- Optional parameter, providing this will link the provided messages to the current.- Returns:
- The created
Span.
-
createInternalSpan
Deprecated.Description copied from interface:SpanFactoryCreates a newSpanlinked to the currently active span. This is useful for tracing different parts of framework logic, so we can time what has the most impact.In monitoring systems, this Span will be part of another trace.
- Specified by:
createInternalSpanin interfaceSpanFactory- Parameters:
operationNameSupplier- Supplier of the operation's name.- Returns:
- The created
Span.
-
createInternalSpan
Deprecated.Description copied from interface:SpanFactoryCreates a newSpanlinked to the currently active span. This is useful for tracing different parts of framework logic, so we can time what has the most impact.The message supplied is used to provide a clearer name, based on
SpanUtils.determineMessageName(Message), and to add the message's attributes to the span.In monitoring systems, this Span will be part of another trace.
- Specified by:
createInternalSpanin interfaceSpanFactory- Parameters:
operationNameSupplier- Supplier of the operation's name.- Returns:
- The created
Span.
-
registerSpanAttributeProvider
Deprecated.Description copied from interface:SpanFactoryRegisters an additionalSpanAttributesProviderto the factory.- Specified by:
registerSpanAttributeProviderin interfaceSpanFactory- Parameters:
provider- The provider to add.
-
propagateContext
Deprecated.Description copied from interface:SpanFactoryPropagates the currently active trace and span to the message. It should do so in a way that the context can be retrieved by theSpanFactory.createLinkedHandlerSpan(Supplier, Message, Message[])method. The most efficient method currently known is to enhance the message's metadata.Since messages are immutable, the method returns the enhanced message. This enhanced message should be used during dispatch instead of the original message.
- Specified by:
propagateContextin interfaceSpanFactory- Type Parameters:
M- The message's type.- Parameters:
message- The message to enhance.- Returns:
- The enhanced message.
-
CommandBus,EventProcessorandQueryBus. Use thedistributedInSameTraceof these instead.