Use slf4j placeholders instead of manually joining log messages
MODIFY
instrumentation/apache-camel-2.20/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachecamel/decorators/RestSpanDecorator.java
instrumentation/apache-camel-2.20/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachecamel/decorators/RestSpanDecorator.java
@@ -52,7 +52,7 @@ class RestSpanDecorator extends HttpSpanDecorator {
try {
path = URLDecoder.decode(path, "UTF-8");
} catch (UnsupportedEncodingException e) {
- LOG.debug("Failed to decode URL path '" + path + "', ignoring exception", e);
+ LOG.debug("Failed to decode URL path '{}', ignoring exception", path, e);
}
}
}

MODIFY
instrumentation/jms-1.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jms/MessagePropertySetter.java
instrumentation/jms-1.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jms/MessagePropertySetter.java
@@ -23,7 +23,7 @@ final class MessagePropertySetter implements TextMapSetter<MessageWithDestinatio
carrier.getMessage().setStringProperty(propName, value);
} catch (JMSException e) {
if (log.isDebugEnabled()) {
- log.debug("Failure setting jms property: " + propName, e);
+ log.debug("Failure setting jms property: {}", propName, e);
}
}
}

MODIFY
javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/AgentInstaller.java
javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/AgentInstaller.java
@@ -313,8 +313,7 @@ public class AgentInstaller {
public Iterable<? extends List<Class<?>>> onError(
int index, List<Class<?>> batch, Throwable throwable, List<Class<?>> types) {
if (log.isDebugEnabled()) {
- log.debug(
- "Exception while retransforming " + batch.size() + " classes: " + batch, throwable);
+ log.debug("Exception while retransforming {} classes: {}", batch.size(), batch, throwable);
}
return Collections.emptyList();
}
@@ -534,7 +533,7 @@ public class AgentInstaller {
private static void logVersionInfo() {
VersionLogger.logAllVersions();
log.debug(
- AgentInstaller.class.getName() + " loaded on " + AgentInstaller.class.getClassLoader());
+ "{} loaded on {}", AgentInstaller.class.getName(), AgentInstaller.class.getClassLoader());
}
private static class NoopIgnoreMatcherProvider implements IgnoreMatcherProvider {

MODIFY
javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/AgentTracerProviderConfigurer.java
javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/AgentTracerProviderConfigurer.java
@@ -76,7 +76,7 @@ public class AgentTracerProviderConfigurer implements SdkTracerProviderConfigure
try {
url = new File(exporterJar).toURI().toURL();
} catch (MalformedURLException e) {
- log.warn("Filename could not be parsed: " + exporterJar + ". Exporter is not installed");
+ log.warn("Filename could not be parsed: {}. Exporter is not installed", exporterJar);
log.warn("No valid exporter found. Tracing will run but spans are dropped");
return;
}
@@ -120,7 +120,7 @@ public class AgentTracerProviderConfigurer implements SdkTracerProviderConfigure
SpanExporter spanExporter = spanExporterFactory.fromConfig(config.asJavaProperties());
SpanProcessor spanProcessor = BatchSpanProcessor.builder(spanExporter).build();
builder.addSpanProcessor(spanProcessor);
- log.info("Installed span exporter: " + spanExporter.getClass().getName());
+ log.info("Installed span exporter: {}", spanExporter.getClass().getName());
}
private static void installMetricExporter(
@@ -130,6 +130,6 @@ public class AgentTracerProviderConfigurer implements SdkTracerProviderConfigure
.setMetricExporter(metricExporter)
.setMetricProducers(Collections.singleton((SdkMeterProvider) GlobalMeterProvider.get()))
.buildAndStart();
- log.info("Installed metric exporter: " + metricExporter.getClass().getName());
+ log.info("Installed metric exporter: {}", metricExporter.getClass().getName());
}
}

Use slf4j placeholders instead of manually joining log messages (#3180)