test: verify StackdriverLogstashEncoder selects correct MDC trace provider in OTel examples - #456
Merged
skjolber merged 1 commit intoAug 15, 2026
Conversation
…t MDC provider selection Co-authored-by: skjolber <1031478+skjolber@users.noreply.github.com>
Copilot
AI
changed the title
test: add ProviderSelectionTest to all OTel examples verifying MDC provider selection
test: verify StackdriverLogstashEncoder selects correct MDC trace provider in OTel examples
Aug 15, 2026
Copilot created this pull request from a session on behalf of
skjolber
August 15, 2026 19:57
View session
skjolber
marked this pull request as ready for review
August 15, 2026 20:02
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.
PR #450 introduces two MDC JSON providers selected at startup —
StackdriverOpenTelemetryTraceMdcJsonProvider(OTel agent) vsStackdriverMicrometerTraceMdcJsonProvider(Spring Boot starter / no agent) — but had no tests asserting which one was actually wired into the encoder.Changes
ProviderSelectionTestto all 8 OpenTelemetry example modules (web + gRPC × agent + starter × with/without test artifacts)StackdriverOpenTelemetryTraceMdcJsonProvideris present (OTel-javaagentattached viabuild.gradle)StackdriverMicrometerTraceMdcJsonProvideris present (default whenisOtelAgent()returns false)Each test walks the Logback appender tree at runtime to retrieve the live encoder instance, handling both the test-scope
CompositeConsoleAppender(viagetMachineReadableJsonEncoder()) and the productionConsoleAppender(viagetEncoder()):Then asserts exactly one provider type is present and the other is absent.