docs: document EventPublishingContextWrapper required for OTel log correlation#1440
Open
won-seoop wants to merge 1 commit into
Open
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The OTel setup documentation at
docs/modules/ROOT/pages/api.adocshows how to wireSlf4JEventListenerandSlf4JBaggageEventListenerinto anOtelTracer, but it was missing a critical step: registeringEventPublishingContextWrapperwith OTel'sContextStorage.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.adocAdd an
IMPORTANTcallout after theotel_setupcode block:ContextStorage.addWrapper(new EventPublishingContextWrapper(eventPublisher))one-linerNOTEthat Spring Boot's autoconfiguration handles this automatically, so the step is only needed for non-Boot setupsdocs/src/test/java/.../TracingApiTests.javaExtract the inline event publisher lambda into a named
eventPublisherfield so the docs snippet clearly shows what object to pass toEventPublishingContextWrapper.Closes #1144
🤖 Generated with Claude Code