Skip to content

Commit 05e2854

Browse files
heyamstrask
andauthored
Support metircIntervalSeconds backward compatibility (#2893)
#2875 --------- Co-authored-by: Trask Stalnaker <[email protected]>
1 parent 8fd1147 commit 05e2854

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,8 @@ public static class PreviewConfiguration {
303303
// this is just here to detect if using this old setting in order to give a helpful message
304304
@Deprecated public boolean openTelemetryApiSupport;
305305
public PreviewInstrumentation instrumentation = new PreviewInstrumentation();
306-
// this is just here to detect if using this old setting in order to give a helpful message
306+
// these are just here to detect if using this old setting in order to give a helpful message
307+
@Deprecated public int metricIntervalSeconds = 60;
307308
@Deprecated public Boolean ignoreRemoteParentNotSampled;
308309
public boolean captureControllerSpans;
309310
// this is just here to detect if using this old setting in order to give a helpful message

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

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ public class ConfigurationBuilder {
9999
private static final String APPLICATIONINSIGHTS_PREVIEW_PROFILER_ENABLEDIAGNOSTICS =
100100
"APPLICATIONINSIGHTS_PREVIEW_PROFILER_ENABLEDIAGNOSTICS";
101101

102+
@Deprecated
103+
private static final String APPLICATIONINSIGHTS_PREVIEW_METRIC_INTERVAL_SECONDS =
104+
"APPLICATIONINSIGHTS_PREVIEW_METRIC_INTERVAL_SECONDS";
105+
102106
private static final String APPLICATIONINSIGHTS_METRIC_INTERVAL_SECONDS =
103107
"APPLICATIONINSIGHTS_METRIC_INTERVAL_SECONDS";
104108

@@ -149,6 +153,13 @@ private static void logConfigurationWarnings(Configuration config) {
149153
"\"openTelemetryApiSupport\" is no longer in preview and it is now the"
150154
+ " (one and only) default behavior");
151155
}
156+
if (config.preview.metricIntervalSeconds != 60) {
157+
configurationLogger.warn(
158+
"\"metricIntervalSeconds\" is no longer in preview and it has been GA since 3.4.9");
159+
if (config.metricIntervalSeconds == 60) {
160+
config.metricIntervalSeconds = config.preview.metricIntervalSeconds;
161+
}
162+
}
152163
if (config.preview.instrumentation.azureSdk.enabled) {
153164
configurationLogger.warn(
154165
"\"azureSdk\" instrumentation is no longer in preview"
@@ -557,9 +568,21 @@ static void overlayFromEnv(Configuration config, Path baseDir) throws IOExceptio
557568
overlayWithEnvVar(
558569
APPLICATIONINSIGHTS_SELF_DIAGNOSTICS_FILE_PATH, config.selfDiagnostics.file.path);
559570

560-
config.metricIntervalSeconds =
561-
overlayWithEnvVar(
562-
APPLICATIONINSIGHTS_METRIC_INTERVAL_SECONDS, config.metricIntervalSeconds);
571+
String deprecatedMetricIntervalSeconds =
572+
getEnvVar(APPLICATIONINSIGHTS_PREVIEW_METRIC_INTERVAL_SECONDS);
573+
String metricIntervalSeconds = getEnvVar(APPLICATIONINSIGHTS_METRIC_INTERVAL_SECONDS);
574+
if (metricIntervalSeconds != null) {
575+
config.metricIntervalSeconds =
576+
overlayWithEnvVar(
577+
APPLICATIONINSIGHTS_METRIC_INTERVAL_SECONDS, config.metricIntervalSeconds);
578+
} else if (deprecatedMetricIntervalSeconds != null) {
579+
configurationLogger.warn(
580+
"\"APPLICATIONINSIGHTS_PREVIEW_METRIC_INTERVAL_SECONDS\" has been renamed to \"APPLICATIONINSIGHTS_METRIC_INTERVAL_SECONDS\""
581+
+ " in 3.4.9 (GA)");
582+
config.metricIntervalSeconds =
583+
overlayWithEnvVar(
584+
APPLICATIONINSIGHTS_PREVIEW_METRIC_INTERVAL_SECONDS, config.metricIntervalSeconds);
585+
}
563586

564587
config.preview.instrumentation.springIntegration.enabled =
565588
overlayWithEnvVar(

0 commit comments

Comments
 (0)