Skip to content

Commit

Permalink
Support metircIntervalSeconds backward compatibility (#2893)
Browse files Browse the repository at this point in the history
#2875

---------

Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
  • Loading branch information
heyams and trask authored Jan 31, 2023
1 parent 8fd1147 commit 05e2854
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,8 @@ public static class PreviewConfiguration {
// this is just here to detect if using this old setting in order to give a helpful message
@Deprecated public boolean openTelemetryApiSupport;
public PreviewInstrumentation instrumentation = new PreviewInstrumentation();
// this is just here to detect if using this old setting in order to give a helpful message
// these are just here to detect if using this old setting in order to give a helpful message
@Deprecated public int metricIntervalSeconds = 60;
@Deprecated public Boolean ignoreRemoteParentNotSampled;
public boolean captureControllerSpans;
// this is just here to detect if using this old setting in order to give a helpful message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ public class ConfigurationBuilder {
private static final String APPLICATIONINSIGHTS_PREVIEW_PROFILER_ENABLEDIAGNOSTICS =
"APPLICATIONINSIGHTS_PREVIEW_PROFILER_ENABLEDIAGNOSTICS";

@Deprecated
private static final String APPLICATIONINSIGHTS_PREVIEW_METRIC_INTERVAL_SECONDS =
"APPLICATIONINSIGHTS_PREVIEW_METRIC_INTERVAL_SECONDS";

private static final String APPLICATIONINSIGHTS_METRIC_INTERVAL_SECONDS =
"APPLICATIONINSIGHTS_METRIC_INTERVAL_SECONDS";

Expand Down Expand Up @@ -149,6 +153,13 @@ private static void logConfigurationWarnings(Configuration config) {
"\"openTelemetryApiSupport\" is no longer in preview and it is now the"
+ " (one and only) default behavior");
}
if (config.preview.metricIntervalSeconds != 60) {
configurationLogger.warn(
"\"metricIntervalSeconds\" is no longer in preview and it has been GA since 3.4.9");
if (config.metricIntervalSeconds == 60) {
config.metricIntervalSeconds = config.preview.metricIntervalSeconds;
}
}
if (config.preview.instrumentation.azureSdk.enabled) {
configurationLogger.warn(
"\"azureSdk\" instrumentation is no longer in preview"
Expand Down Expand Up @@ -557,9 +568,21 @@ static void overlayFromEnv(Configuration config, Path baseDir) throws IOExceptio
overlayWithEnvVar(
APPLICATIONINSIGHTS_SELF_DIAGNOSTICS_FILE_PATH, config.selfDiagnostics.file.path);

config.metricIntervalSeconds =
overlayWithEnvVar(
APPLICATIONINSIGHTS_METRIC_INTERVAL_SECONDS, config.metricIntervalSeconds);
String deprecatedMetricIntervalSeconds =
getEnvVar(APPLICATIONINSIGHTS_PREVIEW_METRIC_INTERVAL_SECONDS);
String metricIntervalSeconds = getEnvVar(APPLICATIONINSIGHTS_METRIC_INTERVAL_SECONDS);
if (metricIntervalSeconds != null) {
config.metricIntervalSeconds =
overlayWithEnvVar(
APPLICATIONINSIGHTS_METRIC_INTERVAL_SECONDS, config.metricIntervalSeconds);
} else if (deprecatedMetricIntervalSeconds != null) {
configurationLogger.warn(
"\"APPLICATIONINSIGHTS_PREVIEW_METRIC_INTERVAL_SECONDS\" has been renamed to \"APPLICATIONINSIGHTS_METRIC_INTERVAL_SECONDS\""
+ " in 3.4.9 (GA)");
config.metricIntervalSeconds =
overlayWithEnvVar(
APPLICATIONINSIGHTS_PREVIEW_METRIC_INTERVAL_SECONDS, config.metricIntervalSeconds);
}

config.preview.instrumentation.springIntegration.enabled =
overlayWithEnvVar(
Expand Down

0 comments on commit 05e2854

Please sign in to comment.