AxonFramework icon indicating copy to clipboard operation
AxonFramework copied to clipboard

Native Tracing for Axon Framework with OpenTelemetry as default

Open CodeDrivenMitch opened this issue 4 years ago • 6 comments

Making Axon Framework tracing-native would benefit customer's applications greatly. We can trace sub-parts of the entire process, for example showing the process of rebuilding the aggregate separately from the entire command execution.

Axon Framework currently does not have the right extension points to support tracing in this way. For example, due to the asynchronous nature of the AxonServerCommandBus the context of tracing is lost. This PR adds new ways to propagate this context and make tracing a lot better.

The default implementation used for this is OpenTelemetry, which is quickly becoming the standard and is backward-compatible with already existing tools like Jaeger and Zipkin.

The OpenTracing plugin can also implement the SpanFactory abstraction, so this can also easily be supported in the same improved way.

This pull request will resolve issue #90 from the Axon Tracing Extension.

CodeDrivenMitch avatar Jul 18 '22 20:07 CodeDrivenMitch

This is how a trace of a Saga currently looks like:

image

Note that it denotes:

  • The TrackingEventProcessor
  • Fetching of Saga data
  • Invocation of each matching Saga and its consequences (such as commands)
  • Loading times of the aggregate, publishing of events
  • Note the Span link on the last event, which triggers another Saga. You can click through to this one.

CodeDrivenMitch avatar Aug 01 '22 09:08 CodeDrivenMitch

The trace of a normal command invocation, such as when using a Spring scheduled method, looks like the following:

image

Again, the aggregate loading times are visible, as well as publishing of events. The events link to asynchronous actions, such as Tracking event processors, Saga's and snapshotter invocations. These are measured separately

CodeDrivenMitch avatar Aug 01 '22 09:08 CodeDrivenMitch

Deadlines are also included in the traces. The actual invocation of the Deadline is measured separately and linked to the trace that was active when the deadline was set.

image

The actual invocation of the deadline looks like this in the case of an aggregate:

image

CodeDrivenMitch avatar Aug 01 '22 09:08 CodeDrivenMitch

Regular event handlers are also traced

image

CodeDrivenMitch avatar Aug 01 '22 09:08 CodeDrivenMitch

Queries are traced as well. Direct queries:

image

Subscription queries are traced in two ways. The initial result is one trace: image

Publishing a new result will link that trace to the subscription query trace image

And vice versa image

Streaming queries are also supported: image

CodeDrivenMitch avatar Aug 01 '22 10:08 CodeDrivenMitch

Be sure to fix the merge conflicts though ;-) And, check whether SonarCloud has anything interesting left to say.

smcvb avatar Sep 05 '22 13:09 smcvb