Skip to content

Commit 0a7f081

Browse files
🐛 fix(observability): wire OpenTelemetry propagator + nest async event handlers
Axon's `OpenTelemetryAutoConfiguration` (4.13) builds `OpenTelemetrySpanFactory.builder().build()` without injecting Spring's `OpenTelemetry` bean, falling back to `GlobalOpenTelemetry` — which is no-op when using `micrometer-tracing-bridge-otel`. Result: silent context loss across async boundaries. - `TracingConfiguration`: explicit `tracer` + `contextPropagators` from Micrometer-managed `OpenTelemetry` - `application.yaml`: `axon.tracing.event-processor.distributed-in-same-trace: true` so pooled processors join the originating trace within the time limit
1 parent d10e0d0 commit 0a7f081

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

src/main/java/com/dddheroes/heroesofddd/shared/infrastructure/TracingConfiguration.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@ class TracingConfiguration {
1212

1313
@Bean
1414
OpenTelemetrySpanFactory openTelemetrySpanFactory(OpenTelemetry openTelemetry) {
15+
// Both tracer AND propagator must come from the same Micrometer-managed OpenTelemetry —
16+
// otherwise the Builder falls back to no-op GlobalOpenTelemetry.getPropagators() and
17+
// propagateContext() / createHandlerSpan() silently lose the W3C trace context across
18+
// async boundaries (event processors, deadlines, Axon Server gRPC).
1519
return OpenTelemetrySpanFactory.builder()
1620
.tracer(openTelemetry.getTracer("axon-framework"))
21+
.contextPropagators(openTelemetry.getPropagators().getTextMapPropagator())
1722
.build();
1823
}
1924
}

src/main/resources/application.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ axon:
7070
tracing:
7171
# All Axon attribute providers stay at their defaults (true)
7272
show-event-sourcing-handlers: false
73+
event-processor:
74+
# Nest async (StreamingEventProcessor / pooled) event handler spans into the trace
75+
# that published the event, when handled within the time limit below. Off by default.
76+
distributed-in-same-trace: true
77+
distributed-in-same-trace-time-limit: 2m
7378
# update-check:
7479
# disabled: true
7580

0 commit comments

Comments
 (0)