Repository navigation
Use mdc-attributes.included instead of deprecated capture-mdc-attributes - #4893
Merged
Merged
Conversation
Avoids the SelectorConfig deprecation warning logged at every startup since OpenTelemetry Java Instrumentation 2.31. Also removes the log4j capture-context-data-attributes property which is no longer read upstream. Fixes #4890 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rajkumar Rangaraj (rajkumar-rangaraj)
requested a balanced review from Copilot
November 12, 2026 00:05
Copilot started reviewing on behalf of
Rajkumar Rangaraj (rajkumar-rangaraj)
November 12, 2026 00:06
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the MDC capture configuration update.
No open issues 🎉
What changed in this PR
Updates the agent’s MDC capture configuration to remove startup deprecation warnings introduced by OpenTelemetry instrumentation 2.31, addressing #4890 while preserving capture of all MDC attributes.
Changes:
- Uses
mdc-attributes.included=*for Logback, Log4j, and JBoss LogManager. - Removes the obsolete Log4j context-data capture property.
- Documents the fix in the changelog; leaves map-message capture unchanged.
| File | Description |
|---|---|
| CHANGELOG.md | Records the startup deprecation warning fix. |
| agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init/AiConfigCustomizer.java | Replaces deprecated MDC settings and removes the obsolete Log4j property. |
Review effort: Balanced
xiang17
approved these changes
Nov 12, 2026
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.
Fix #4890 .
Since OpenTelemetry Java Instrumentation 2.31, the logback, log4j and jboss-logmanager appenders resolve MDC capture through
SelectorConfig, which logs a deprecation warning when the old*.experimental.capture-mdc-attributesproperty is used.AiConfigCustomizersets those properties itself, so every agent startup logged the warning and users couldn't suppress it.Changes:
otel.instrumentation.{logback-appender,log4j-appender,jboss-logmanager}.experimental.capture-mdc-attributes=*with the corresponding...experimental.mdc-attributes.included=*. With the new glob semantics,*still captures all MDC/context data attributes, so captured telemetry is unchanged.otel.instrumentation.log4j-appender.experimental.capture-context-data-attributes, which is no longer read upstream (log4j context data is covered bylog4j-appender.experimental.mdc-attributes).Not changed here: the agent also sets
otel.instrumentation.log4j-appender.experimental.capture-map-message-attributes=true, which logs a similar deprecation warning. Its replacement (otel.instrumentation.common.logging.structured-attributes.included) is a common setting that would also enable SLF4J key-value pair and Logstash marker capture for logback, which changes behavior, so it should be handled separately.Validation:
./gradlew :smoke-tests:apps:Log4j2:smokeTest --tests "*Log4j2Test$Tomcat8Java8Test": passed (2 tests; assertsMDC keyis captured, and the container output no longer has thecapture-mdc-attributeswarning)./gradlew :smoke-tests:apps:Logback:smokeTest --tests "*LogbackTest$Tomcat8Java8Test": passed (2 tests; assertsMDC keyis captured, and noSelectorConfigwarning in the output)For significant contributions please make sure you have completed the following items: