From 325477e6f63702bd6ef7edf1cf38b6eb76dcc2cd Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Thu, 4 Jan 2024 18:25:51 +0100 Subject: [PATCH] log4j MDC attribute capture configuration (#10054) --- instrumentation/log4j/log4j-appender-2.17/javaagent/README.md | 2 +- .../log4j/log4j-appender-2.17/javaagent/build.gradle.kts | 2 +- .../instrumentation/log4j/appender/v2_17/Log4jHelper.java | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/instrumentation/log4j/log4j-appender-2.17/javaagent/README.md b/instrumentation/log4j/log4j-appender-2.17/javaagent/README.md index 72b581fcd108..be4f9f763848 100644 --- a/instrumentation/log4j/log4j-appender-2.17/javaagent/README.md +++ b/instrumentation/log4j/log4j-appender-2.17/javaagent/README.md @@ -5,6 +5,6 @@ | `otel.instrumentation.log4j-appender.experimental-log-attributes` | Boolean | `false` | Enable the capture of experimental log attributes `thread.name` and `thread.id`. | | `otel.instrumentation.log4j-appender.experimental.capture-map-message-attributes` | Boolean | `false` | Enable the capture of `MapMessage` attributes. | | `otel.instrumentation.log4j-appender.experimental.capture-marker-attribute` | Boolean | `false` | Enable the capture of Log4j markers as attributes. | -| `otel.instrumentation.log4j-appender.experimental.capture-context-data-attributes` | String | | Comma separated list of context data attributes to capture. Use the wildcard character `*` to capture all attributes. | +| `otel.instrumentation.log4j-appender.experimental.capture-mdc-attributes` | String | | Comma separated list of context data attributes to capture. Use the wildcard character `*` to capture all attributes. | [source code attributes]: https://github.com/open-telemetry/semantic-conventions/blob/main/docs/general/attributes.md#source-code-attributes diff --git a/instrumentation/log4j/log4j-appender-2.17/javaagent/build.gradle.kts b/instrumentation/log4j/log4j-appender-2.17/javaagent/build.gradle.kts index 6adaec6fa623..2d36da71a27f 100644 --- a/instrumentation/log4j/log4j-appender-2.17/javaagent/build.gradle.kts +++ b/instrumentation/log4j/log4j-appender-2.17/javaagent/build.gradle.kts @@ -57,7 +57,7 @@ tasks { tasks.withType().configureEach { // TODO run tests both with and without experimental log attributes jvmArgs("-Dotel.instrumentation.log4j-appender.experimental.capture-map-message-attributes=true") - jvmArgs("-Dotel.instrumentation.log4j-appender.experimental.capture-context-data-attributes=*") + jvmArgs("-Dotel.instrumentation.log4j-appender.experimental.capture-mdc-attributes=*") jvmArgs("-Dotel.instrumentation.log4j-appender.experimental-log-attributes=true") jvmArgs("-Dotel.instrumentation.log4j-appender.experimental.capture-marker-attribute=true") } diff --git a/instrumentation/log4j/log4j-appender-2.17/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/log4j/appender/v2_17/Log4jHelper.java b/instrumentation/log4j/log4j-appender-2.17/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/log4j/appender/v2_17/Log4jHelper.java index 0bd3cbeee8f1..3c228dafa1f5 100644 --- a/instrumentation/log4j/log4j-appender-2.17/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/log4j/appender/v2_17/Log4jHelper.java +++ b/instrumentation/log4j/log4j-appender-2.17/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/log4j/appender/v2_17/Log4jHelper.java @@ -43,8 +43,7 @@ public final class Log4jHelper { "otel.instrumentation.log4j-appender.experimental.capture-marker-attribute", false); List captureContextDataAttributes = config.getList( - "otel.instrumentation.log4j-appender.experimental.capture-context-data-attributes", - emptyList()); + "otel.instrumentation.log4j-appender.experimental.capture-mdc-attributes", emptyList()); mapper = new LogEventMapper<>(