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 4d3ed8a00856..a7f1d9c58012 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 @@ -170,9 +170,10 @@ private void mapLoggingEvent( captureLoggerContext(attributes, loggingEvent.getLoggerContextVO().getPropertyMap()); } - if (captureArguments && - loggingEvent.getArgumentArray()!=null && loggingEvent.getArgumentArray().length > 0) { - captureArguments(attributes, loggingEvent.getMessage(), loggingEvent.getArgumentArray()); + if (captureArguments + && loggingEvent.getArgumentArray() != null + && loggingEvent.getArgumentArray().length > 0) { + captureArguments(attributes, loggingEvent.getMessage(), loggingEvent.getArgumentArray()); } builder.setAllAttributes(attributes.build()); @@ -198,12 +199,12 @@ void captureMdcAttributes(AttributesBuilder attributes, Map mdcP } } - void captureArguments(AttributesBuilder attributes, String message, Object[] arguments){ + void captureArguments(AttributesBuilder attributes, String message, Object[] arguments) { attributes.put("src_msg_", message); - for (int idx = 0; idx < arguments.length; idx++) { - Object argument = arguments[idx]; - attributes.put("log_arg_" + idx, String.valueOf(argument)); - } + for (int idx = 0; idx < arguments.length; idx++) { + Object argument = arguments[idx]; + attributes.put("log_arg_" + idx, String.valueOf(argument)); + } } public static AttributeKey getMdcAttributeKey(String key) { diff --git a/instrumentation/logback/logback-appender-1.0/library/src/slf4j2ApiTest/java/io/opentelemetry/instrumentation/logback/appender/v1_0/Slf4j2Test.java b/instrumentation/logback/logback-appender-1.0/library/src/slf4j2ApiTest/java/io/opentelemetry/instrumentation/logback/appender/v1_0/Slf4j2Test.java index df68972d5593..2f72826df766 100644 --- a/instrumentation/logback/logback-appender-1.0/library/src/slf4j2ApiTest/java/io/opentelemetry/instrumentation/logback/appender/v1_0/Slf4j2Test.java +++ b/instrumentation/logback/logback-appender-1.0/library/src/slf4j2ApiTest/java/io/opentelemetry/instrumentation/logback/appender/v1_0/Slf4j2Test.java @@ -117,7 +117,9 @@ void multipleMarkers() { void arguments() { logger .atInfo() - .setMessage("log message {} and {}").addArgument("'world'").addArgument(Math.PI) + .setMessage("log message {} and {}") + .addArgument("'world'") + .addArgument(Math.PI) .log(); List logDataList = logRecordExporter.getFinishedLogRecordItems(); @@ -127,13 +129,11 @@ void arguments() { assertThat(logData.getResource()).isEqualTo(resource); assertThat(logData.getInstrumentationScopeInfo()).isEqualTo(instrumentationScopeInfo); assertThat(logData.getBody().asString()).isEqualTo("log message 'world' and 3.141592653589793"); - assertThat(logData.getAttributes().size()) - .isEqualTo(7); + assertThat(logData.getAttributes().size()).isEqualTo(7); assertThat(logData) .hasAttributesSatisfying( equalTo(AttributeKey.stringKey("log_arg_0"), "'world'"), equalTo(AttributeKey.stringKey("log_arg_1"), "3.141592653589793"), - equalTo(AttributeKey.stringKey("src_msg_"), "log message {} and {}") - ); + equalTo(AttributeKey.stringKey("src_msg_"), "log message {} and {}")); } }