From 554d1726b4003dcd25aad6f1399b4761fd66eae9 Mon Sep 17 00:00:00 2001 From: Baptiste Foy Date: Thu, 27 Feb 2025 10:53:49 +0100 Subject: [PATCH 1/2] fix(stable_config): Fix telemetry source names --- .../src/main/java/datadog/trace/api/ConfigOrigin.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal-api/src/main/java/datadog/trace/api/ConfigOrigin.java b/internal-api/src/main/java/datadog/trace/api/ConfigOrigin.java index 78cf4e20e2b..f8844f6ac3c 100644 --- a/internal-api/src/main/java/datadog/trace/api/ConfigOrigin.java +++ b/internal-api/src/main/java/datadog/trace/api/ConfigOrigin.java @@ -8,9 +8,9 @@ public enum ConfigOrigin { /** configurations that are set through JVM properties */ JVM_PROP("jvm_prop"), /** configuration read in the stable config file, managed by users */ - USER_STABLE_CONFIG("user_stable_config"), + USER_STABLE_CONFIG("local_stable_config"), /** configuration read in the stable config file, managed by fleet */ - MANAGED_STABLE_CONFIG("managed_stable_config"), + MANAGED_STABLE_CONFIG("fleet_stable_config"), /** set when the user has not set any configuration for the key (defaults to a value) */ DEFAULT("default"); From 2fb1466b5754a7b59600cb9293422a42fd95e60a Mon Sep 17 00:00:00 2001 From: Baptiste Foy Date: Thu, 27 Feb 2025 15:35:52 +0100 Subject: [PATCH 2/2] refactor: change variable names too --- .../java/datadog/trace/bootstrap/Agent.java | 8 +++---- .../java/datadog/trace/api/ConfigOrigin.java | 4 ++-- .../config/provider/ConfigProvider.java | 24 +++++++++---------- .../config/provider/StableConfigSource.java | 12 +++++----- .../provider/StableConfigSourceTest.groovy | 10 ++++---- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/Agent.java b/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/Agent.java index 71291eb0be1..c0b79066e9b 100644 --- a/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/Agent.java +++ b/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/Agent.java @@ -1213,13 +1213,13 @@ private static boolean isFeatureEnabled(AgentFeature feature) { final String featureSystemProp = feature.getSystemProp(); String featureEnabled = System.getProperty(featureSystemProp); if (featureEnabled == null) { - featureEnabled = getStableConfig(StableConfigSource.MANAGED, featureConfigKey); + featureEnabled = getStableConfig(StableConfigSource.FLEET, featureConfigKey); } if (featureEnabled == null) { featureEnabled = ddGetEnv(featureSystemProp); } if (featureEnabled == null) { - featureEnabled = getStableConfig(StableConfigSource.USER, featureConfigKey); + featureEnabled = getStableConfig(StableConfigSource.LOCAL, featureConfigKey); } if (feature.isEnabledByDefault()) { @@ -1243,13 +1243,13 @@ private static boolean isFullyDisabled(final AgentFeature feature) { final String featureSystemProp = feature.getSystemProp(); String settingValue = getNullIfEmpty(System.getProperty(featureSystemProp)); if (settingValue == null) { - settingValue = getNullIfEmpty(getStableConfig(StableConfigSource.MANAGED, featureConfigKey)); + settingValue = getNullIfEmpty(getStableConfig(StableConfigSource.FLEET, featureConfigKey)); } if (settingValue == null) { settingValue = getNullIfEmpty(ddGetEnv(featureSystemProp)); } if (settingValue == null) { - settingValue = getNullIfEmpty(getStableConfig(StableConfigSource.USER, featureConfigKey)); + settingValue = getNullIfEmpty(getStableConfig(StableConfigSource.LOCAL, featureConfigKey)); } // defaults to inactive diff --git a/internal-api/src/main/java/datadog/trace/api/ConfigOrigin.java b/internal-api/src/main/java/datadog/trace/api/ConfigOrigin.java index f8844f6ac3c..c51a07c8c0e 100644 --- a/internal-api/src/main/java/datadog/trace/api/ConfigOrigin.java +++ b/internal-api/src/main/java/datadog/trace/api/ConfigOrigin.java @@ -8,9 +8,9 @@ public enum ConfigOrigin { /** configurations that are set through JVM properties */ JVM_PROP("jvm_prop"), /** configuration read in the stable config file, managed by users */ - USER_STABLE_CONFIG("local_stable_config"), + LOCAL_STABLE_CONFIG("local_stable_config"), /** configuration read in the stable config file, managed by fleet */ - MANAGED_STABLE_CONFIG("fleet_stable_config"), + FLEET_STABLE_CONFIG("fleet_stable_config"), /** set when the user has not set any configuration for the key (defaults to a value) */ DEFAULT("default"); diff --git a/internal-api/src/main/java/datadog/trace/bootstrap/config/provider/ConfigProvider.java b/internal-api/src/main/java/datadog/trace/bootstrap/config/provider/ConfigProvider.java index 60acd7330ae..90e43cd30ab 100644 --- a/internal-api/src/main/java/datadog/trace/bootstrap/config/provider/ConfigProvider.java +++ b/internal-api/src/main/java/datadog/trace/bootstrap/config/provider/ConfigProvider.java @@ -356,19 +356,19 @@ public static ConfigProvider createDefault() { if (configProperties.isEmpty()) { return new ConfigProvider( new SystemPropertiesConfigSource(), - StableConfigSource.MANAGED, + StableConfigSource.FLEET, new EnvironmentConfigSource(), new OtelEnvironmentConfigSource(), - StableConfigSource.USER, + StableConfigSource.LOCAL, new CapturedEnvironmentConfigSource()); } else { return new ConfigProvider( new SystemPropertiesConfigSource(), - StableConfigSource.MANAGED, + StableConfigSource.FLEET, new EnvironmentConfigSource(), new PropertiesConfigSource(configProperties, true), new OtelEnvironmentConfigSource(configProperties), - StableConfigSource.USER, + StableConfigSource.LOCAL, new CapturedEnvironmentConfigSource()); } } @@ -382,20 +382,20 @@ public static ConfigProvider withoutCollector() { return new ConfigProvider( false, new SystemPropertiesConfigSource(), - StableConfigSource.MANAGED, + StableConfigSource.FLEET, new EnvironmentConfigSource(), new OtelEnvironmentConfigSource(), - StableConfigSource.USER, + StableConfigSource.LOCAL, new CapturedEnvironmentConfigSource()); } else { return new ConfigProvider( false, new SystemPropertiesConfigSource(), - StableConfigSource.MANAGED, + StableConfigSource.FLEET, new EnvironmentConfigSource(), new PropertiesConfigSource(configProperties, true), new OtelEnvironmentConfigSource(configProperties), - StableConfigSource.USER, + StableConfigSource.LOCAL, new CapturedEnvironmentConfigSource()); } } @@ -411,21 +411,21 @@ public static ConfigProvider withPropertiesOverride(Properties properties) { if (configProperties.isEmpty()) { return new ConfigProvider( new SystemPropertiesConfigSource(), - StableConfigSource.MANAGED, + StableConfigSource.FLEET, new EnvironmentConfigSource(), providedConfigSource, new OtelEnvironmentConfigSource(), - StableConfigSource.USER, + StableConfigSource.LOCAL, new CapturedEnvironmentConfigSource()); } else { return new ConfigProvider( providedConfigSource, new SystemPropertiesConfigSource(), - StableConfigSource.MANAGED, + StableConfigSource.FLEET, new EnvironmentConfigSource(), new PropertiesConfigSource(configProperties, true), new OtelEnvironmentConfigSource(configProperties), - StableConfigSource.USER, + StableConfigSource.LOCAL, new CapturedEnvironmentConfigSource()); } } diff --git a/internal-api/src/main/java/datadog/trace/bootstrap/config/provider/StableConfigSource.java b/internal-api/src/main/java/datadog/trace/bootstrap/config/provider/StableConfigSource.java index f95dd71d33d..df4603e891f 100644 --- a/internal-api/src/main/java/datadog/trace/bootstrap/config/provider/StableConfigSource.java +++ b/internal-api/src/main/java/datadog/trace/bootstrap/config/provider/StableConfigSource.java @@ -12,15 +12,15 @@ public final class StableConfigSource extends ConfigProvider.Source { private static final Logger log = LoggerFactory.getLogger(StableConfigSource.class); - public static final String USER_STABLE_CONFIG_PATH = + public static final String LOCAL_STABLE_CONFIG_PATH = "/etc/datadog-agent/application_monitoring.yaml"; - public static final String MANAGED_STABLE_CONFIG_PATH = + public static final String FLEET_STABLE_CONFIG_PATH = "/etc/datadog-agent/managed/datadog-agent/stable/application_monitoring.yaml"; - public static final StableConfigSource USER = - new StableConfigSource(USER_STABLE_CONFIG_PATH, ConfigOrigin.USER_STABLE_CONFIG); - public static final StableConfigSource MANAGED = + public static final StableConfigSource LOCAL = + new StableConfigSource(LOCAL_STABLE_CONFIG_PATH, ConfigOrigin.LOCAL_STABLE_CONFIG); + public static final StableConfigSource FLEET = new StableConfigSource( - StableConfigSource.MANAGED_STABLE_CONFIG_PATH, ConfigOrigin.MANAGED_STABLE_CONFIG); + StableConfigSource.FLEET_STABLE_CONFIG_PATH, ConfigOrigin.FLEET_STABLE_CONFIG); private final ConfigOrigin fileOrigin; diff --git a/internal-api/src/test/groovy/datadog/trace/bootstrap/config/provider/StableConfigSourceTest.groovy b/internal-api/src/test/groovy/datadog/trace/bootstrap/config/provider/StableConfigSourceTest.groovy index ad0bbb252b9..890ab15a7b9 100644 --- a/internal-api/src/test/groovy/datadog/trace/bootstrap/config/provider/StableConfigSourceTest.groovy +++ b/internal-api/src/test/groovy/datadog/trace/bootstrap/config/provider/StableConfigSourceTest.groovy @@ -14,7 +14,7 @@ class StableConfigSourceTest extends DDSpecification { def "test file doesn't exist"() { setup: - StableConfigSource config = new StableConfigSource(StableConfigSource.USER_STABLE_CONFIG_PATH, ConfigOrigin.USER_STABLE_CONFIG) + StableConfigSource config = new StableConfigSource(StableConfigSource.LOCAL_STABLE_CONFIG_PATH, ConfigOrigin.LOCAL_STABLE_CONFIG) expect: config.getKeys().size() == 0 @@ -27,7 +27,7 @@ class StableConfigSourceTest extends DDSpecification { if (filePath == null) { throw new AssertionError("Failed to create test file") } - StableConfigSource config = new StableConfigSource(filePath.toString(), ConfigOrigin.USER_STABLE_CONFIG) + StableConfigSource config = new StableConfigSource(filePath.toString(), ConfigOrigin.LOCAL_STABLE_CONFIG) then: config.getKeys().size() == 0 @@ -49,7 +49,7 @@ class StableConfigSourceTest extends DDSpecification { throw new AssertionError("Failed to write to file: ${e.message}") } - StableConfigSource cfg = new StableConfigSource(filePath.toString(), ConfigOrigin.USER_STABLE_CONFIG) + StableConfigSource cfg = new StableConfigSource(filePath.toString(), ConfigOrigin.LOCAL_STABLE_CONFIG) then: cfg.get("service") == "svc" @@ -74,7 +74,7 @@ class StableConfigSourceTest extends DDSpecification { throw new AssertionError("Failed to write to file: ${e.message}") } - StableConfigSource stableCfg = new StableConfigSource(filePath.toString(), ConfigOrigin.USER_STABLE_CONFIG) + StableConfigSource stableCfg = new StableConfigSource(filePath.toString(), ConfigOrigin.LOCAL_STABLE_CONFIG) then: stableCfg.getConfigId() == null @@ -100,7 +100,7 @@ class StableConfigSourceTest extends DDSpecification { throw new AssertionError("Failed to write to file: ${e.message}") } - StableConfigSource stableCfg = new StableConfigSource(filePath.toString(), ConfigOrigin.USER_STABLE_CONFIG) + StableConfigSource stableCfg = new StableConfigSource(filePath.toString(), ConfigOrigin.LOCAL_STABLE_CONFIG) then: for (key in configs.keySet()) {