Skip to content

Commit 7b98085

Browse files
authored
Add capability to turn off logback instrumentation (#3082)
1 parent d76835e commit 7b98085

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init/AiConfigCustomizer.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public Map<String, String> apply(ConfigProperties otelConfig) {
2525
"applicationinsights.internal.micrometer.step.millis",
2626
Long.toString(SECONDS.toMillis(configuration.metricIntervalSeconds)));
2727

28-
enableInstrumentations(configuration, properties);
28+
enableInstrumentations(otelConfig, configuration, properties);
2929

3030
if (!configuration.preview.captureControllerSpans) {
3131
properties.put(
@@ -116,7 +116,8 @@ public Map<String, String> apply(ConfigProperties otelConfig) {
116116
return properties;
117117
}
118118

119-
private static void enableInstrumentations(Configuration config, Map<String, String> properties) {
119+
private static void enableInstrumentations(
120+
ConfigProperties otelConfig, Configuration config, Map<String, String> properties) {
120121
properties.put("otel.instrumentation.common.default-enabled", "false");
121122

122123
properties.put("otel.instrumentation.experimental.span-suppression-strategy", "client");
@@ -148,7 +149,9 @@ private static void enableInstrumentations(Configuration config, Map<String, Str
148149
properties.put("otel.instrumentation.liberty.enabled", "true");
149150
properties.put("otel.instrumentation.liberty-dispatcher.enabled", "true");
150151
properties.put("otel.instrumentation.log4j-appender.enabled", "true");
151-
properties.put("otel.instrumentation.logback-appender.enabled", "true");
152+
if (otelConfig.getBoolean("otel.instrumentation.logback-appender.enabled", true)) {
153+
properties.put("otel.instrumentation.logback-appender.enabled", "true");
154+
}
152155
properties.put("otel.instrumentation.log4j-mdc.enabled", "true");
153156
properties.put("otel.instrumentation.log4j-context-data.enabled", "true");
154157
properties.put("otel.instrumentation.logback-mdc.enabled", "true");

0 commit comments

Comments
 (0)