Skip to content

docs: document EventPublishingContextWrapper required for OTel log correlation#1440

Open
won-seoop wants to merge 1 commit into
micrometer-metrics:mainfrom
won-seoop:doc-otel-event-publishing-context-wrapper
Open

docs: document EventPublishingContextWrapper required for OTel log correlation#1440
won-seoop wants to merge 1 commit into
micrometer-metrics:mainfrom
won-seoop:doc-otel-event-publishing-context-wrapper

Conversation

@won-seoop

Copy link
Copy Markdown

Problem

The OTel setup documentation at docs/modules/ROOT/pages/api.adoc shows how to wire Slf4JEventListener and Slf4JBaggageEventListener into an OtelTracer, but it was missing a critical step: registering EventPublishingContextWrapper with OTel's ContextStorage.

Without this step, the listeners never receive scope-change events, so SLF4J MDC is never populated with traceId/spanId, breaking log correlation even though everything else looks correctly configured.

Changes

docs/modules/ROOT/pages/api.adoc

Add an IMPORTANT callout after the otel_setup code block:

  • Shows the missing ContextStorage.addWrapper(new EventPublishingContextWrapper(eventPublisher)) one-liner
  • Adds a NOTE that Spring Boot's autoconfiguration handles this automatically, so the step is only needed for non-Boot setups

docs/src/test/java/.../TracingApiTests.java

Extract the inline event publisher lambda into a named eventPublisher field so the docs snippet clearly shows what object to pass to EventPublishingContextWrapper.

Closes #1144

🤖 Generated with Claude Code

…rrelation

The OTel setup section was missing a critical step: registering
EventPublishingContextWrapper with ContextStorage. Without it,
Slf4JEventListener and Slf4JBaggageEventListener do not fire and
MDC is never populated with traceId/spanId, breaking log correlation.

Changes:
- Add IMPORTANT callout in api.adoc after the otel_setup snippet,
  showing the ContextStorage.addWrapper(new EventPublishingContextWrapper(...))
  call with a note that this is handled automatically by Spring Boot autoconfiguration
- Refactor the test's inlined event publisher lambda into a named field
  so it is visible in the otel_setup code snippet, making it clear
  what to pass to EventPublishingContextWrapper

Closes micrometer-metrics#1144

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OTel Tracer Not Propagating Events - Missing Steps in Docs.

1 participant