Skip to content

Commit 58bf5cf

Browse files
authored
Update default configuration (#1888)
* Enable AzureSdk and OTel instrumentation by default * Disable controller spans by default
1 parent fd53d13 commit 58bf5cf

File tree

31 files changed

+367
-520
lines changed

31 files changed

+367
-520
lines changed

agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/configuration/Configuration.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ public static class JmxMetric {
134134

135135
public static class Instrumentation {
136136

137+
public EnabledByDefaultInstrumentation azureSdk = new EnabledByDefaultInstrumentation();
137138
public EnabledByDefaultInstrumentation cassandra = new EnabledByDefaultInstrumentation();
138139
public EnabledByDefaultInstrumentation jdbc = new EnabledByDefaultInstrumentation();
139140
public EnabledByDefaultInstrumentation jms = new EnabledByDefaultInstrumentation();
@@ -184,7 +185,8 @@ public static class PreviewConfiguration {
184185

185186
public SamplingPreview sampling = new SamplingPreview();
186187
public List<ProcessorConfig> processors = new ArrayList<>();
187-
public boolean openTelemetryApiSupport;
188+
// this is just here to detect if using this old setting in order to give a helpful message
189+
@Deprecated public boolean openTelemetryApiSupport;
188190
public PreviewInstrumentation instrumentation = new PreviewInstrumentation();
189191
// applies to perf counters, default custom metrics, jmx metrics, and micrometer metrics
190192
// not sure if we'll be able to have different metric intervals in future OpenTelemetry metrics
@@ -194,7 +196,7 @@ public static class PreviewConfiguration {
194196
// ignoreRemoteParentNotSampled is currently needed
195197
// because .NET SDK always propagates trace flags "00" (not sampled)
196198
public boolean ignoreRemoteParentNotSampled = true;
197-
public boolean captureControllerSpans = true;
199+
public boolean captureControllerSpans;
198200
// this is just here to detect if using this old setting in order to give a helpful message
199201
@Deprecated public boolean httpMethodInOperationName;
200202
public LiveMetrics liveMetrics = new LiveMetrics();
@@ -264,6 +266,8 @@ public static class InternalConfiguration {
264266
}
265267

266268
public static class PreviewInstrumentation {
269+
// this is just here to detect if using this old setting in order to give a helpful message
270+
@Deprecated
267271
public DisabledByDefaultInstrumentation azureSdk = new DisabledByDefaultInstrumentation();
268272

269273
public DisabledByDefaultInstrumentation grizzly = new DisabledByDefaultInstrumentation();

agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/configuration/ConfigurationBuilder.java

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,6 @@ public class ConfigurationBuilder {
8080
public static final String APPLICATIONINSIGHTS_SELF_DIAGNOSTICS_FILE_PATH =
8181
"APPLICATIONINSIGHTS_SELF_DIAGNOSTICS_FILE_PATH";
8282

83-
private static final String APPLICATIONINSIGHTS_PREVIEW_OTEL_API_SUPPORT =
84-
"APPLICATIONINSIGHTS_PREVIEW_OTEL_API_SUPPORT";
85-
private static final String APPLICATIONINSIGHTS_PREVIEW_INSTRUMENTATION_AZURE_SDK_ENABLED =
86-
"APPLICATIONINSIGHTS_PREVIEW_INSTRUMENTATION_AZURE_SDK_ENABLED";
8783
private static final String
8884
APPLICATIONINSIGHTS_PREVIEW_INSTRUMENTATION_SPRING_INTEGRATION_ENABLED =
8985
"APPLICATIONINSIGHTS_PREVIEW_INSTRUMENTATION_SPRING_INTEGRATION_ENABLED";
@@ -125,7 +121,19 @@ public static Configuration create(Path agentJarPath, RpConfiguration rpConfigur
125121
}
126122
if (config.preview.httpMethodInOperationName) {
127123
configurationLogger.warn(
128-
"\"httpMethodInOperationName\" preview setting is now the (one and only) default behavior");
124+
"\"httpMethodInOperationName\" is no longer in preview and it is now the"
125+
+ " (one and only) default behavior");
126+
}
127+
if (config.preview.openTelemetryApiSupport) {
128+
configurationLogger.warn(
129+
"\"openTelemetryApiSupport\" is no longer in preview and it is now the"
130+
+ " (one and only) default behavior");
131+
}
132+
if (config.preview.instrumentation.azureSdk.enabled) {
133+
configurationLogger.warn(
134+
"\"azureSdk\" instrumentation is no longer in preview"
135+
+ " and it is now enabled by default,"
136+
+ " so no need to enable it under preview configuration");
129137
}
130138
if (config.preview.instrumentation.javaHttpClient.enabled) {
131139
configurationLogger.warn(
@@ -145,6 +153,7 @@ public static Configuration create(Path agentJarPath, RpConfiguration rpConfigur
145153
+ " and it is now enabled by default,"
146154
+ " so no need to enable it under preview configuration");
147155
}
156+
148157
overlayEnvVars(config);
149158
applySamplingPercentageRounding(config);
150159
// rp configuration should always be last (so it takes precedence)
@@ -249,6 +258,10 @@ private static boolean jmxMetricExists(
249258
}
250259

251260
private static void overlayInstrumentationEnabledEnvVars(Configuration config) {
261+
config.instrumentation.azureSdk.enabled =
262+
overlayWithEnvVar(
263+
"APPLICATIONINSIGHTS_INSTRUMENTATION_AZURE_SDK_ENABLED",
264+
config.instrumentation.azureSdk.enabled);
252265
config.instrumentation.cassandra.enabled =
253266
overlayWithEnvVar(
254267
"APPLICATIONINSIGHTS_INSTRUMENTATION_CASSANDRA_ENABLED",
@@ -383,13 +396,6 @@ static void overlayEnvVars(Configuration config) throws IOException {
383396
APPLICATIONINSIGHTS_PREVIEW_METRIC_INTERVAL_SECONDS,
384397
config.preview.metricIntervalSeconds);
385398

386-
config.preview.openTelemetryApiSupport =
387-
overlayWithEnvVar(
388-
APPLICATIONINSIGHTS_PREVIEW_OTEL_API_SUPPORT, config.preview.openTelemetryApiSupport);
389-
config.preview.instrumentation.azureSdk.enabled =
390-
overlayWithEnvVar(
391-
APPLICATIONINSIGHTS_PREVIEW_INSTRUMENTATION_AZURE_SDK_ENABLED,
392-
config.preview.instrumentation.azureSdk.enabled);
393399
config.preview.instrumentation.springIntegration.enabled =
394400
overlayWithEnvVar(
395401
APPLICATIONINSIGHTS_PREVIEW_INSTRUMENTATION_SPRING_INTEGRATION_ENABLED,

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

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ static Config getConfig(Configuration config) {
4242
properties.put("otel.instrumentation.micrometer.enabled", "false");
4343
properties.put("otel.instrumentation.actuator-metrics.enabled", "false");
4444
}
45+
if (!config.instrumentation.azureSdk.enabled) {
46+
properties.put("otel.instrumentation.azure-core.enabled", "false");
47+
}
4548
if (!config.instrumentation.cassandra.enabled) {
4649
properties.put("otel.instrumentation.cassandra.enabled", "false");
4750
}
@@ -68,17 +71,6 @@ static Config getConfig(Configuration config) {
6871
if (!config.instrumentation.springScheduling.enabled) {
6972
properties.put("otel.instrumentation.spring-scheduling.enabled", "false");
7073
}
71-
if (!config.preview.openTelemetryApiSupport) {
72-
properties.put("otel.instrumentation.opentelemetry-api.enabled", "false");
73-
properties.put("otel.instrumentation.opentelemetry-api-metrics.enabled", "false");
74-
// TODO (trask) this is old name, remove after updating to version that has
75-
// this: https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/3611
76-
properties.put("otel.instrumentation.opentelemetry-metrics-api.enabled", "false");
77-
properties.put("otel.instrumentation.opentelemetry-annotations.enabled", "false");
78-
}
79-
if (!config.preview.instrumentation.azureSdk.enabled) {
80-
properties.put("otel.instrumentation.azure-core.enabled", "false");
81-
}
8274
if (config.preview.instrumentation.grizzly.enabled) {
8375
// grizzly instrumentation is off by default
8476
// TODO (trask) investigate if grizzly instrumentation can be enabled upstream by default now

agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/statsbeat/FeatureStatsbeat.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ void trackConfigurationOptions(Configuration config) {
9797
}
9898

9999
// disabled instrumentations
100+
if (!config.instrumentation.azureSdk.enabled) {
101+
featureList.add(Feature.AZURE_SDK_DISABLED);
102+
}
100103
if (!config.instrumentation.cassandra.enabled) {
101104
featureList.add(Feature.CASSANDRA_DISABLED);
102105
}
@@ -126,9 +129,6 @@ void trackConfigurationOptions(Configuration config) {
126129
}
127130

128131
// preview instrumentation
129-
if (!config.preview.instrumentation.azureSdk.enabled) {
130-
featureList.add(Feature.AZURE_SDK_DISABLED);
131-
}
132132
if (!config.preview.instrumentation.grizzly.enabled) {
133133
featureList.add(Feature.GRIZZLY_DISABLED);
134134
}

agent/agent-tooling/src/test/java/com/microsoft/applicationinsights/agent/internal/configuration/ConfigurationTest.java

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -481,43 +481,33 @@ void shouldOverrideSelfDiagnosticsFilePath() throws IOException {
481481
}
482482

483483
@Test
484-
void shouldOverridePreviewOtelApiSupport() throws IOException {
485-
envVars.set("APPLICATIONINSIGHTS_PREVIEW_OTEL_API_SUPPORT", "true");
486-
487-
Configuration configuration = loadConfiguration();
488-
ConfigurationBuilder.overlayEnvVars(configuration);
489-
490-
assertThat(configuration.preview.openTelemetryApiSupport).isTrue();
491-
}
492-
493-
@Test
494-
void shouldOverridePreviewAzureSdkInstrumentation() throws IOException {
495-
envVars.set("APPLICATIONINSIGHTS_PREVIEW_INSTRUMENTATION_AZURE_SDK_ENABLED", "true");
484+
void shouldOverridePreviewSpringIntegrationInstrumentation() throws IOException {
485+
envVars.set("APPLICATIONINSIGHTS_PREVIEW_INSTRUMENTATION_SPRING_INTEGRATION_ENABLED", "true");
496486

497487
Configuration configuration = loadConfiguration();
498488
ConfigurationBuilder.overlayEnvVars(configuration);
499489

500-
assertThat(configuration.preview.instrumentation.azureSdk.enabled).isTrue();
490+
assertThat(configuration.preview.instrumentation.springIntegration.enabled).isTrue();
501491
}
502492

503493
@Test
504-
void shouldOverridePreviewSpringIntegrationInstrumentation() throws IOException {
505-
envVars.set("APPLICATIONINSIGHTS_PREVIEW_INSTRUMENTATION_SPRING_INTEGRATION_ENABLED", "true");
494+
void shouldOverridePreviewLiveMetricsEnabled() throws IOException {
495+
envVars.set("APPLICATIONINSIGHTS_PREVIEW_LIVE_METRICS_ENABLED", "false");
506496

507497
Configuration configuration = loadConfiguration();
508498
ConfigurationBuilder.overlayEnvVars(configuration);
509499

510-
assertThat(configuration.preview.instrumentation.springIntegration.enabled).isTrue();
500+
assertThat(configuration.preview.liveMetrics.enabled).isFalse();
511501
}
512502

513503
@Test
514-
void shouldOverridePreviewLiveMetricsEnabled() throws IOException {
515-
envVars.set("APPLICATIONINSIGHTS_PREVIEW_LIVE_METRICS_ENABLED", "false");
504+
void shouldOverrideInstrumentationAzureSdkEnabled() throws IOException {
505+
envVars.set("APPLICATIONINSIGHTS_INSTRUMENTATION_AZURE_SDK_ENABLED", "false");
516506

517507
Configuration configuration = loadConfiguration();
518508
ConfigurationBuilder.overlayEnvVars(configuration);
519509

520-
assertThat(configuration.preview.liveMetrics.enabled).isFalse();
510+
assertThat(configuration.instrumentation.azureSdk.enabled).isFalse();
521511
}
522512

523513
@Test

agent/agent-tooling/src/test/java/com/microsoft/applicationinsights/agent/internal/statsbeat/FeatureStatsbeatTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ private static Configuration newConfiguration() {
151151
config.preview = new Configuration.PreviewConfiguration();
152152
config.preview.instrumentation = new Configuration.PreviewInstrumentation();
153153
// preview instrumentation is disabled by default
154-
config.preview.instrumentation.azureSdk.enabled = true;
155154
config.preview.instrumentation.springIntegration.enabled = true;
156155
return config;
157156
}

test/smoke/appServers/global-resources/controller_spans_disabled_azuresdk_applicationinsights.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

test/smoke/appServers/global-resources/controller_spans_disabled_default_applicationinsights.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

test/smoke/appServers/global-resources/controller_spans_disabled_opentelemetryapisupport_applicationinsights.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

test/smoke/appServers/global-resources/opentelemetryapisupport_applicationinsights.json renamed to test/smoke/appServers/global-resources/controller_spans_enabled_applicationinsights.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
"instance": "testroleinstance"
66
},
77
"preview": {
8-
"openTelemetryApiSupport": true
8+
"captureControllerSpans": true
99
}
1010
}

0 commit comments

Comments
 (0)