From 8c3b45a34550eecc386ea9af2313a0a08f33ad7b Mon Sep 17 00:00:00 2001 From: Jean Bisutti Date: Mon, 19 Sep 2022 05:50:23 -0700 Subject: [PATCH 1/5] Add marker attribute for Logback --- .../javaagent/build.gradle.kts | 1 + .../appender/v1_0/LogbackSingletons.java | 8 ++++++- .../logback/appender/v1_0/LogbackTest.java | 22 +++++++++++++++++++ .../src/test/resources/logback-test.xml | 1 + .../appender/v1_0/OpenTelemetryAppender.java | 16 +++++++++++++- .../v1_0/internal/LoggingEventMapper.java | 16 +++++++++++++- .../v1_0/OpenTelemetryAppenderConfigTest.java | 12 ++++++++-- .../v1_0/internal/LoggingEventMapperTest.java | 6 ++--- .../src/test/resources/logback-test.xml | 1 + 9 files changed, 75 insertions(+), 8 deletions(-) diff --git a/instrumentation/logback/logback-appender-1.0/javaagent/build.gradle.kts b/instrumentation/logback/logback-appender-1.0/javaagent/build.gradle.kts index 0f6b34623c90..ecb18bfec677 100644 --- a/instrumentation/logback/logback-appender-1.0/javaagent/build.gradle.kts +++ b/instrumentation/logback/logback-appender-1.0/javaagent/build.gradle.kts @@ -56,4 +56,5 @@ tasks.withType().configureEach { jvmArgs("-Dotel.instrumentation.logback-appender.experimental.capture-mdc-attributes=*") jvmArgs("-Dotel.instrumentation.logback-appender.experimental-log-attributes=true") jvmArgs("-Dotel.instrumentation.logback-appender.experimental.capture-code-attributes=true") + jvmArgs("-Dotel.instrumentation.logback-appender.experimental.capture-marker-attributes=true") } diff --git a/instrumentation/logback/logback-appender-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/logback/appender/v1_0/LogbackSingletons.java b/instrumentation/logback/logback-appender-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/logback/appender/v1_0/LogbackSingletons.java index 6789d3567ab0..9bde91f18bff 100644 --- a/instrumentation/logback/logback-appender-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/logback/appender/v1_0/LogbackSingletons.java +++ b/instrumentation/logback/logback-appender-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/logback/appender/v1_0/LogbackSingletons.java @@ -24,6 +24,9 @@ public final class LogbackSingletons { boolean captureCodeAttributes = config.getBoolean( "otel.instrumentation.logback-appender.experimental.capture-code-attributes", false); + boolean captureMarkerAttributes = + config.getBoolean( + "otel.instrumentation.logback-appender.experimental.capture-marker-attributes", false); List captureMdcAttributes = config.getList( "otel.instrumentation.logback-appender.experimental.capture-mdc-attributes", @@ -31,7 +34,10 @@ public final class LogbackSingletons { mapper = new LoggingEventMapper( - captureExperimentalAttributes, captureMdcAttributes, captureCodeAttributes); + captureExperimentalAttributes, + captureMdcAttributes, + captureCodeAttributes, + captureMarkerAttributes); } public static LoggingEventMapper mapper() { diff --git a/instrumentation/logback/logback-appender-1.0/javaagent/src/test/java/io/opentelemetry/instrumentation/logback/appender/v1_0/LogbackTest.java b/instrumentation/logback/logback-appender-1.0/javaagent/src/test/java/io/opentelemetry/instrumentation/logback/appender/v1_0/LogbackTest.java index 3c0fa46f8023..ae108fe42e2e 100644 --- a/instrumentation/logback/logback-appender-1.0/javaagent/src/test/java/io/opentelemetry/instrumentation/logback/appender/v1_0/LogbackTest.java +++ b/instrumentation/logback/logback-appender-1.0/javaagent/src/test/java/io/opentelemetry/instrumentation/logback/appender/v1_0/LogbackTest.java @@ -26,6 +26,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.MDC; +import org.slf4j.Marker; +import org.slf4j.MarkerFactory; class LogbackTest extends AgentInstrumentationSpecification { @@ -34,6 +36,7 @@ class LogbackTest extends AgentInstrumentationSpecification { private static final Logger abcLogger = LoggerFactory.getLogger("abc"); private static final Logger defLogger = LoggerFactory.getLogger("def"); + private static final Logger ghiLogger = LoggerFactory.getLogger("ghi"); private static Stream provideParameters() { return Stream.of( @@ -219,6 +222,25 @@ void testMdc() { .containsEntry(SemanticAttributes.CODE_FILEPATH, "LogbackTest.java")); } + @Test + public void testMarker() { + + String markerName = "aMarker"; + Marker marker = MarkerFactory.getMarker(markerName); + + ghiLogger.info(marker, "Message"); + + await().untilAsserted(() -> assertThat(testing.logs().size()).isEqualTo(1)); + + LogData log = getLogs().get(0); + + assertThat(log) + .hasAttributesSatisfying( + attributes -> + assertThat(attributes) + .containsEntry(AttributeKey.stringKey("log.marker"), markerName)); + } + private static void performLogging( Logger logger, OneArgLoggerMethod oneArgLoggerMethod, diff --git a/instrumentation/logback/logback-appender-1.0/javaagent/src/test/resources/logback-test.xml b/instrumentation/logback/logback-appender-1.0/javaagent/src/test/resources/logback-test.xml index aec9ea6c14e3..6c4700b9b945 100644 --- a/instrumentation/logback/logback-appender-1.0/javaagent/src/test/resources/logback-test.xml +++ b/instrumentation/logback/logback-appender-1.0/javaagent/src/test/resources/logback-test.xml @@ -11,6 +11,7 @@ + diff --git a/instrumentation/logback/logback-appender-1.0/library/src/main/java/io/opentelemetry/instrumentation/logback/appender/v1_0/OpenTelemetryAppender.java b/instrumentation/logback/logback-appender-1.0/library/src/main/java/io/opentelemetry/instrumentation/logback/appender/v1_0/OpenTelemetryAppender.java index 2f2c13760f6e..19b78ccc8b63 100644 --- a/instrumentation/logback/logback-appender-1.0/library/src/main/java/io/opentelemetry/instrumentation/logback/appender/v1_0/OpenTelemetryAppender.java +++ b/instrumentation/logback/logback-appender-1.0/library/src/main/java/io/opentelemetry/instrumentation/logback/appender/v1_0/OpenTelemetryAppender.java @@ -26,6 +26,7 @@ public class OpenTelemetryAppender extends UnsynchronizedAppenderBase captureMdcAttributes = emptyList(); private volatile LoggingEventMapper mapper; @@ -36,7 +37,10 @@ public OpenTelemetryAppender() {} public void start() { mapper = new LoggingEventMapper( - captureExperimentalAttributes, captureMdcAttributes, captureCodeAttributes); + captureExperimentalAttributes, + captureMdcAttributes, + captureCodeAttributes, + captureMarkerAttributes); super.start(); } @@ -77,6 +81,16 @@ public void setCaptureCodeAttributes(boolean captureCodeAttributes) { this.captureCodeAttributes = captureCodeAttributes; } + /** + * Sets whether the marker attributes (file name, class name, method name and line number) should + * be set to logs. + * + * @param captureMarkerAttributes To enable or disable the marker attributes + */ + public void setCaptureMarkerAttributes(boolean captureMarkerAttributes) { + this.captureMarkerAttributes = captureMarkerAttributes; + } + /** Configures the {@link MDC} attributes that will be copied to logs. */ public void setCaptureMdcAttributes(String attributes) { if (attributes != null) { diff --git a/instrumentation/logback/logback-appender-1.0/library/src/main/java/io/opentelemetry/instrumentation/logback/appender/v1_0/internal/LoggingEventMapper.java b/instrumentation/logback/logback-appender-1.0/library/src/main/java/io/opentelemetry/instrumentation/logback/appender/v1_0/internal/LoggingEventMapper.java index 576e32395237..cf25e962bc15 100644 --- a/instrumentation/logback/logback-appender-1.0/library/src/main/java/io/opentelemetry/instrumentation/logback/appender/v1_0/internal/LoggingEventMapper.java +++ b/instrumentation/logback/logback-appender-1.0/library/src/main/java/io/opentelemetry/instrumentation/logback/appender/v1_0/internal/LoggingEventMapper.java @@ -22,6 +22,7 @@ import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; +import org.slf4j.Marker; /** * This class is internal and is hence not for public use. Its APIs are unstable and can change at @@ -31,18 +32,23 @@ public final class LoggingEventMapper { private static final Cache> mdcAttributeKeys = Cache.bounded(100); + private static final AttributeKey LOG_MARKER = AttributeKey.stringKey("log.marker"); + private final boolean captureExperimentalAttributes; private final List captureMdcAttributes; private final boolean captureAllMdcAttributes; private final boolean captureCodeAttributes; + private final boolean captureMarkerAttributes; public LoggingEventMapper( boolean captureExperimentalAttributes, List captureMdcAttributes, - boolean captureCodeAttributes) { + boolean captureCodeAttributes, + boolean captureMarkerAttributes) { this.captureExperimentalAttributes = captureExperimentalAttributes; this.captureCodeAttributes = captureCodeAttributes; this.captureMdcAttributes = captureMdcAttributes; + this.captureMarkerAttributes = captureMarkerAttributes; this.captureAllMdcAttributes = captureMdcAttributes.size() == 1 && captureMdcAttributes.get(0).equals("*"); } @@ -125,6 +131,14 @@ private void mapLoggingEvent(LogRecordBuilder builder, ILoggingEvent loggingEven } } + if (captureMarkerAttributes) { + Marker marker = loggingEvent.getMarker(); + if (marker != null) { + String markerName = marker.getName(); + attributes.put(LOG_MARKER, markerName); + } + } + builder.setAllAttributes(attributes.build()); // span context diff --git a/instrumentation/logback/logback-appender-1.0/library/src/test/java/io/opentelemetry/instrumentation/logback/appender/v1_0/OpenTelemetryAppenderConfigTest.java b/instrumentation/logback/logback-appender-1.0/library/src/test/java/io/opentelemetry/instrumentation/logback/appender/v1_0/OpenTelemetryAppenderConfigTest.java index 06853ba75784..696e89e8fff1 100644 --- a/instrumentation/logback/logback-appender-1.0/library/src/test/java/io/opentelemetry/instrumentation/logback/appender/v1_0/OpenTelemetryAppenderConfigTest.java +++ b/instrumentation/logback/logback-appender-1.0/library/src/test/java/io/opentelemetry/instrumentation/logback/appender/v1_0/OpenTelemetryAppenderConfigTest.java @@ -30,6 +30,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.MDC; +import org.slf4j.Marker; +import org.slf4j.MarkerFactory; class OpenTelemetryAppenderConfigTest { @@ -101,7 +103,9 @@ private static Span runWithSpan(String spanName, Runnable runnable) { @Test void logWithExtras() { Instant start = Instant.now(); - logger.info("log message 1", new IllegalStateException("Error!")); + String markerName = "aMarker"; + Marker marker = MarkerFactory.getMarker(markerName); + logger.info(marker, "log message 1", new IllegalStateException("Error!")); List logDataList = logExporter.getFinishedLogItems(); assertThat(logDataList).hasSize(1); @@ -114,7 +118,8 @@ void logWithExtras() { .isLessThan(TimeUnit.MILLISECONDS.toNanos(Instant.now().toEpochMilli())); assertThat(logData.getSeverity()).isEqualTo(Severity.INFO); assertThat(logData.getSeverityText()).isEqualTo("INFO"); - assertThat(logData.getAttributes().size()).isEqualTo(3 + 4); // 4 code attributes + assertThat(logData.getAttributes().size()) + .isEqualTo(3 + 4 + 1); // 3 exception attributes, 4 code attributes, 1 marker attribute assertThat(logData.getAttributes().get(SemanticAttributes.EXCEPTION_TYPE)) .isEqualTo(IllegalStateException.class.getName()); assertThat(logData.getAttributes().get(SemanticAttributes.EXCEPTION_MESSAGE)) @@ -135,6 +140,9 @@ void logWithExtras() { Long lineNumber = logData.getAttributes().get(SemanticAttributes.CODE_LINENO); assertThat(lineNumber).isGreaterThan(1); + + String logMarker = logData.getAttributes().get(AttributeKey.stringKey("log.marker")); + assertThat(logMarker).isEqualTo(markerName); } @Test diff --git a/instrumentation/logback/logback-appender-1.0/library/src/test/java/io/opentelemetry/instrumentation/logback/appender/v1_0/internal/LoggingEventMapperTest.java b/instrumentation/logback/logback-appender-1.0/library/src/test/java/io/opentelemetry/instrumentation/logback/appender/v1_0/internal/LoggingEventMapperTest.java index f4b6ac530412..5c0567f6b6d6 100644 --- a/instrumentation/logback/logback-appender-1.0/library/src/test/java/io/opentelemetry/instrumentation/logback/appender/v1_0/internal/LoggingEventMapperTest.java +++ b/instrumentation/logback/logback-appender-1.0/library/src/test/java/io/opentelemetry/instrumentation/logback/appender/v1_0/internal/LoggingEventMapperTest.java @@ -22,7 +22,7 @@ class LoggingEventMapperTest { @Test void testDefault() { // given - LoggingEventMapper mapper = new LoggingEventMapper(false, emptyList(), false); + LoggingEventMapper mapper = new LoggingEventMapper(false, emptyList(), false, false); Map contextData = new HashMap<>(); contextData.put("key1", "value1"); contextData.put("key2", "value2"); @@ -38,7 +38,7 @@ void testDefault() { @Test void testSome() { // given - LoggingEventMapper mapper = new LoggingEventMapper(false, singletonList("key2"), false); + LoggingEventMapper mapper = new LoggingEventMapper(false, singletonList("key2"), false, false); Map contextData = new HashMap<>(); contextData.put("key1", "value1"); contextData.put("key2", "value2"); @@ -55,7 +55,7 @@ void testSome() { @Test void testAll() { // given - LoggingEventMapper mapper = new LoggingEventMapper(false, singletonList("*"), false); + LoggingEventMapper mapper = new LoggingEventMapper(false, singletonList("*"), false, false); Map contextData = new HashMap<>(); contextData.put("key1", "value1"); contextData.put("key2", "value2"); diff --git a/instrumentation/logback/logback-appender-1.0/library/src/test/resources/logback-test.xml b/instrumentation/logback/logback-appender-1.0/library/src/test/resources/logback-test.xml index d213483122ee..fc814f1a3eb5 100644 --- a/instrumentation/logback/logback-appender-1.0/library/src/test/resources/logback-test.xml +++ b/instrumentation/logback/logback-appender-1.0/library/src/test/resources/logback-test.xml @@ -12,6 +12,7 @@ class="io.opentelemetry.instrumentation.logback.appender.v1_0.OpenTelemetryAppender"> false true + true * From b5c81ec7b59e7574a6fbaed0c8efea4df7a5d393 Mon Sep 17 00:00:00 2001 From: Jean Bisutti Date: Tue, 20 Sep 2022 01:34:59 -0700 Subject: [PATCH 2/5] Rename attribute --- .../instrumentation/logback/appender/v1_0/LogbackTest.java | 2 +- .../logback/appender/v1_0/internal/LoggingEventMapper.java | 2 +- .../logback/appender/v1_0/OpenTelemetryAppenderConfigTest.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/instrumentation/logback/logback-appender-1.0/javaagent/src/test/java/io/opentelemetry/instrumentation/logback/appender/v1_0/LogbackTest.java b/instrumentation/logback/logback-appender-1.0/javaagent/src/test/java/io/opentelemetry/instrumentation/logback/appender/v1_0/LogbackTest.java index ae108fe42e2e..b4e0c984a20e 100644 --- a/instrumentation/logback/logback-appender-1.0/javaagent/src/test/java/io/opentelemetry/instrumentation/logback/appender/v1_0/LogbackTest.java +++ b/instrumentation/logback/logback-appender-1.0/javaagent/src/test/java/io/opentelemetry/instrumentation/logback/appender/v1_0/LogbackTest.java @@ -238,7 +238,7 @@ public void testMarker() { .hasAttributesSatisfying( attributes -> assertThat(attributes) - .containsEntry(AttributeKey.stringKey("log.marker"), markerName)); + .containsEntry(AttributeKey.stringKey("logback.marker"), markerName)); } private static void performLogging( diff --git a/instrumentation/logback/logback-appender-1.0/library/src/main/java/io/opentelemetry/instrumentation/logback/appender/v1_0/internal/LoggingEventMapper.java b/instrumentation/logback/logback-appender-1.0/library/src/main/java/io/opentelemetry/instrumentation/logback/appender/v1_0/internal/LoggingEventMapper.java index cf25e962bc15..1146e2d425c1 100644 --- a/instrumentation/logback/logback-appender-1.0/library/src/main/java/io/opentelemetry/instrumentation/logback/appender/v1_0/internal/LoggingEventMapper.java +++ b/instrumentation/logback/logback-appender-1.0/library/src/main/java/io/opentelemetry/instrumentation/logback/appender/v1_0/internal/LoggingEventMapper.java @@ -32,7 +32,7 @@ public final class LoggingEventMapper { private static final Cache> mdcAttributeKeys = Cache.bounded(100); - private static final AttributeKey LOG_MARKER = AttributeKey.stringKey("log.marker"); + private static final AttributeKey LOG_MARKER = AttributeKey.stringKey("logback.marker"); private final boolean captureExperimentalAttributes; private final List captureMdcAttributes; diff --git a/instrumentation/logback/logback-appender-1.0/library/src/test/java/io/opentelemetry/instrumentation/logback/appender/v1_0/OpenTelemetryAppenderConfigTest.java b/instrumentation/logback/logback-appender-1.0/library/src/test/java/io/opentelemetry/instrumentation/logback/appender/v1_0/OpenTelemetryAppenderConfigTest.java index 696e89e8fff1..0c7c83bce3ff 100644 --- a/instrumentation/logback/logback-appender-1.0/library/src/test/java/io/opentelemetry/instrumentation/logback/appender/v1_0/OpenTelemetryAppenderConfigTest.java +++ b/instrumentation/logback/logback-appender-1.0/library/src/test/java/io/opentelemetry/instrumentation/logback/appender/v1_0/OpenTelemetryAppenderConfigTest.java @@ -141,7 +141,7 @@ void logWithExtras() { Long lineNumber = logData.getAttributes().get(SemanticAttributes.CODE_LINENO); assertThat(lineNumber).isGreaterThan(1); - String logMarker = logData.getAttributes().get(AttributeKey.stringKey("log.marker")); + String logMarker = logData.getAttributes().get(AttributeKey.stringKey("logback.marker")); assertThat(logMarker).isEqualTo(markerName); } From 975d7e5e7c5cdab855cc9f24719246a611540bcf Mon Sep 17 00:00:00 2001 From: Jean Bisutti Date: Tue, 20 Sep 2022 01:51:51 -0700 Subject: [PATCH 3/5] Renaming --- .../logback/appender/v1_0/LogbackSingletons.java | 4 ++-- .../appender/v1_0/OpenTelemetryAppender.java | 13 ++++++------- .../appender/v1_0/internal/LoggingEventMapper.java | 8 ++++---- .../library/src/test/resources/logback-test.xml | 2 +- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/instrumentation/logback/logback-appender-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/logback/appender/v1_0/LogbackSingletons.java b/instrumentation/logback/logback-appender-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/logback/appender/v1_0/LogbackSingletons.java index 9bde91f18bff..ac9c6e4351a8 100644 --- a/instrumentation/logback/logback-appender-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/logback/appender/v1_0/LogbackSingletons.java +++ b/instrumentation/logback/logback-appender-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/logback/appender/v1_0/LogbackSingletons.java @@ -24,7 +24,7 @@ public final class LogbackSingletons { boolean captureCodeAttributes = config.getBoolean( "otel.instrumentation.logback-appender.experimental.capture-code-attributes", false); - boolean captureMarkerAttributes = + boolean captureMarkerAttribute = config.getBoolean( "otel.instrumentation.logback-appender.experimental.capture-marker-attributes", false); List captureMdcAttributes = @@ -37,7 +37,7 @@ public final class LogbackSingletons { captureExperimentalAttributes, captureMdcAttributes, captureCodeAttributes, - captureMarkerAttributes); + captureMarkerAttribute); } public static LoggingEventMapper mapper() { diff --git a/instrumentation/logback/logback-appender-1.0/library/src/main/java/io/opentelemetry/instrumentation/logback/appender/v1_0/OpenTelemetryAppender.java b/instrumentation/logback/logback-appender-1.0/library/src/main/java/io/opentelemetry/instrumentation/logback/appender/v1_0/OpenTelemetryAppender.java index 19b78ccc8b63..1e9a2107be59 100644 --- a/instrumentation/logback/logback-appender-1.0/library/src/main/java/io/opentelemetry/instrumentation/logback/appender/v1_0/OpenTelemetryAppender.java +++ b/instrumentation/logback/logback-appender-1.0/library/src/main/java/io/opentelemetry/instrumentation/logback/appender/v1_0/OpenTelemetryAppender.java @@ -26,7 +26,7 @@ public class OpenTelemetryAppender extends UnsynchronizedAppenderBase captureMdcAttributes = emptyList(); private volatile LoggingEventMapper mapper; @@ -40,7 +40,7 @@ public void start() { captureExperimentalAttributes, captureMdcAttributes, captureCodeAttributes, - captureMarkerAttributes); + captureMarkerAttribute); super.start(); } @@ -82,13 +82,12 @@ public void setCaptureCodeAttributes(boolean captureCodeAttributes) { } /** - * Sets whether the marker attributes (file name, class name, method name and line number) should - * be set to logs. + * Sets whether the marker attribute should be set to logs. * - * @param captureMarkerAttributes To enable or disable the marker attributes + * @param captureMarkerAttribute To enable or disable the marker attribute */ - public void setCaptureMarkerAttributes(boolean captureMarkerAttributes) { - this.captureMarkerAttributes = captureMarkerAttributes; + public void setCaptureMarkerAttribute(boolean captureMarkerAttribute) { + this.captureMarkerAttribute = captureMarkerAttribute; } /** Configures the {@link MDC} attributes that will be copied to logs. */ diff --git a/instrumentation/logback/logback-appender-1.0/library/src/main/java/io/opentelemetry/instrumentation/logback/appender/v1_0/internal/LoggingEventMapper.java b/instrumentation/logback/logback-appender-1.0/library/src/main/java/io/opentelemetry/instrumentation/logback/appender/v1_0/internal/LoggingEventMapper.java index 1146e2d425c1..ab2a50be7acb 100644 --- a/instrumentation/logback/logback-appender-1.0/library/src/main/java/io/opentelemetry/instrumentation/logback/appender/v1_0/internal/LoggingEventMapper.java +++ b/instrumentation/logback/logback-appender-1.0/library/src/main/java/io/opentelemetry/instrumentation/logback/appender/v1_0/internal/LoggingEventMapper.java @@ -38,17 +38,17 @@ public final class LoggingEventMapper { private final List captureMdcAttributes; private final boolean captureAllMdcAttributes; private final boolean captureCodeAttributes; - private final boolean captureMarkerAttributes; + private final boolean captureMarkerAttribute; public LoggingEventMapper( boolean captureExperimentalAttributes, List captureMdcAttributes, boolean captureCodeAttributes, - boolean captureMarkerAttributes) { + boolean captureMarkerAttribute) { this.captureExperimentalAttributes = captureExperimentalAttributes; this.captureCodeAttributes = captureCodeAttributes; this.captureMdcAttributes = captureMdcAttributes; - this.captureMarkerAttributes = captureMarkerAttributes; + this.captureMarkerAttribute = captureMarkerAttribute; this.captureAllMdcAttributes = captureMdcAttributes.size() == 1 && captureMdcAttributes.get(0).equals("*"); } @@ -131,7 +131,7 @@ private void mapLoggingEvent(LogRecordBuilder builder, ILoggingEvent loggingEven } } - if (captureMarkerAttributes) { + if (captureMarkerAttribute) { Marker marker = loggingEvent.getMarker(); if (marker != null) { String markerName = marker.getName(); diff --git a/instrumentation/logback/logback-appender-1.0/library/src/test/resources/logback-test.xml b/instrumentation/logback/logback-appender-1.0/library/src/test/resources/logback-test.xml index fc814f1a3eb5..a3a4273a1222 100644 --- a/instrumentation/logback/logback-appender-1.0/library/src/test/resources/logback-test.xml +++ b/instrumentation/logback/logback-appender-1.0/library/src/test/resources/logback-test.xml @@ -12,7 +12,7 @@ class="io.opentelemetry.instrumentation.logback.appender.v1_0.OpenTelemetryAppender"> false true - true + true * From 7c7d9852cdec651eab28fcbe5110f54a35d8c2a1 Mon Sep 17 00:00:00 2001 From: Jean Bisutti Date: Tue, 20 Sep 2022 02:00:47 -0700 Subject: [PATCH 4/5] Property renaming --- .../logback/logback-appender-1.0/javaagent/build.gradle.kts | 2 +- .../logback/appender/v1_0/LogbackSingletons.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/instrumentation/logback/logback-appender-1.0/javaagent/build.gradle.kts b/instrumentation/logback/logback-appender-1.0/javaagent/build.gradle.kts index ecb18bfec677..753bb054d8c7 100644 --- a/instrumentation/logback/logback-appender-1.0/javaagent/build.gradle.kts +++ b/instrumentation/logback/logback-appender-1.0/javaagent/build.gradle.kts @@ -56,5 +56,5 @@ tasks.withType().configureEach { jvmArgs("-Dotel.instrumentation.logback-appender.experimental.capture-mdc-attributes=*") jvmArgs("-Dotel.instrumentation.logback-appender.experimental-log-attributes=true") jvmArgs("-Dotel.instrumentation.logback-appender.experimental.capture-code-attributes=true") - jvmArgs("-Dotel.instrumentation.logback-appender.experimental.capture-marker-attributes=true") + jvmArgs("-Dotel.instrumentation.logback-appender.experimental.capture-marker-attribute=true") } diff --git a/instrumentation/logback/logback-appender-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/logback/appender/v1_0/LogbackSingletons.java b/instrumentation/logback/logback-appender-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/logback/appender/v1_0/LogbackSingletons.java index ac9c6e4351a8..a91bf7fcf742 100644 --- a/instrumentation/logback/logback-appender-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/logback/appender/v1_0/LogbackSingletons.java +++ b/instrumentation/logback/logback-appender-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/logback/appender/v1_0/LogbackSingletons.java @@ -26,7 +26,7 @@ public final class LogbackSingletons { "otel.instrumentation.logback-appender.experimental.capture-code-attributes", false); boolean captureMarkerAttribute = config.getBoolean( - "otel.instrumentation.logback-appender.experimental.capture-marker-attributes", false); + "otel.instrumentation.logback-appender.experimental.capture-marker-attribute", false); List captureMdcAttributes = config.getList( "otel.instrumentation.logback-appender.experimental.capture-mdc-attributes", From c1a916727ca68d189276583d2b1728bae20fe349 Mon Sep 17 00:00:00 2001 From: Jean Bisutti Date: Tue, 20 Sep 2022 02:51:43 -0700 Subject: [PATCH 5/5] Test simplification --- .../instrumentation/logback/appender/v1_0/LogbackTest.java | 3 +-- .../javaagent/src/test/resources/logback-test.xml | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/instrumentation/logback/logback-appender-1.0/javaagent/src/test/java/io/opentelemetry/instrumentation/logback/appender/v1_0/LogbackTest.java b/instrumentation/logback/logback-appender-1.0/javaagent/src/test/java/io/opentelemetry/instrumentation/logback/appender/v1_0/LogbackTest.java index b4e0c984a20e..fc2c995aba2c 100644 --- a/instrumentation/logback/logback-appender-1.0/javaagent/src/test/java/io/opentelemetry/instrumentation/logback/appender/v1_0/LogbackTest.java +++ b/instrumentation/logback/logback-appender-1.0/javaagent/src/test/java/io/opentelemetry/instrumentation/logback/appender/v1_0/LogbackTest.java @@ -36,7 +36,6 @@ class LogbackTest extends AgentInstrumentationSpecification { private static final Logger abcLogger = LoggerFactory.getLogger("abc"); private static final Logger defLogger = LoggerFactory.getLogger("def"); - private static final Logger ghiLogger = LoggerFactory.getLogger("ghi"); private static Stream provideParameters() { return Stream.of( @@ -228,7 +227,7 @@ public void testMarker() { String markerName = "aMarker"; Marker marker = MarkerFactory.getMarker(markerName); - ghiLogger.info(marker, "Message"); + abcLogger.info(marker, "Message"); await().untilAsserted(() -> assertThat(testing.logs().size()).isEqualTo(1)); diff --git a/instrumentation/logback/logback-appender-1.0/javaagent/src/test/resources/logback-test.xml b/instrumentation/logback/logback-appender-1.0/javaagent/src/test/resources/logback-test.xml index 6c4700b9b945..aec9ea6c14e3 100644 --- a/instrumentation/logback/logback-appender-1.0/javaagent/src/test/resources/logback-test.xml +++ b/instrumentation/logback/logback-appender-1.0/javaagent/src/test/resources/logback-test.xml @@ -11,7 +11,6 @@ -