Change JMXFetch config keys
`agent.conf.d` -> `jmxfetch.config.dir`
`jmxfetch.configs` -> `jmxfetch.config`
Enabling bundled JMXFetch configs:
`dd.integration.<integration>.enabled=true` -> `dd.jmxfetch.<integration>.enabled=true`
MODIFY
dd-java-agent/agent-jmxfetch/src/main/java/datadog/trace/agent/jmxfetch/JMXFetch.java
dd-java-agent/agent-jmxfetch/src/main/java/datadog/trace/agent/jmxfetch/JMXFetch.java
@@ -47,7 +47,7 @@ public class JMXFetch {
System.setProperty("org.slf4j.simpleLogger.log.org.datadog.jmxfetch", "warn");
}
- final String agentConfDPath = config.getAgentConfDPath();
+ final String jmxFetchConfigDir = config.getJmxFetchConfigDir();
final List<String> jmxFetchConfigs = config.getJmxFetchConfigs();
final List<String> internalMetricsConfigs = getInternalMetricFiles();
final List<String> metricsConfigs = config.getJmxFetchMetricsConfigs();
@@ -60,7 +60,7 @@ public class JMXFetch {
log.info(
"JMXFetch config: {} {} {} {} {} {} {} {} {} {}",
- agentConfDPath,
+ jmxFetchConfigDir,
jmxFetchConfigs,
internalMetricsConfigs,
metricsConfigs,
@@ -74,7 +74,7 @@ public class JMXFetch {
final AppConfig.AppConfigBuilder configBuilder =
AppConfig.builder()
.action(ImmutableList.of(ACTION_COLLECT))
- .confdDirectory(agentConfDPath)
+ .confdDirectory(jmxFetchConfigDir)
.yamlFileList(jmxFetchConfigs)
.targetDirectInstances(true)
.instanceConfigResources(DEFAULT_CONFIGS)
@@ -151,7 +151,7 @@ public class JMXFetch {
for (final String config : split) {
integrationName.clear();
integrationName.add(config.replace(".yaml", ""));
- if (Config.integrationEnabled(integrationName, false)) {
+ if (Config.jmxFetchIntegrationEnabled(integrationName, false)) {
final URL resource = JMXFetch.class.getResource("metricconfigs/" + config);
result.add(resource.getPath().split("\\.jar!/")[1]);
}

MODIFY
dd-java-agent/src/test/groovy/datadog/trace/agent/JMXFetchTest.groovy
dd-java-agent/src/test/groovy/datadog/trace/agent/JMXFetchTest.groovy
@@ -52,7 +52,7 @@ class JMXFetchTest extends Specification {
def "test jmxfetch config"() {
setup:
names.each {
- System.setProperty("dd.integration.${it}.enabled", "$enable")
+ System.setProperty("dd.jmxfetch.${it}.enabled", "$enable")
}
def classLoader = IntegrationTestUtils.getJmxFetchClassLoader()
// Have to set this so JMXFetch knows where to find resources

MODIFY
dd-trace-api/src/main/java/datadog/trace/api/Config.java
dd-trace-api/src/main/java/datadog/trace/api/Config.java
@@ -64,9 +64,9 @@ public class Config {
public static final String PROPAGATION_STYLE_EXTRACT = "propagation.style.extract";
public static final String PROPAGATION_STYLE_INJECT = "propagation.style.inject";
- public static final String AGENT_CONF_D = "agent.conf.d";
public static final String JMX_FETCH_ENABLED = "jmxfetch.enabled";
- public static final String JMX_FETCH_CONFIGS = "jmxfetch.configs";
+ public static final String JMX_FETCH_CONFIG_DIR = "jmxfetch.config.dir";
+ public static final String JMX_FETCH_CONFIG = "jmxfetch.config";
public static final String JMX_FETCH_METRICS_CONFIGS = "jmxfetch.metrics-configs";
public static final String JMX_FETCH_CHECK_PERIOD = "jmxfetch.check-period";
public static final String JMX_FETCH_REFRESH_BEANS_PERIOD = "jmxfetch.refresh-beans-period";
@@ -148,8 +148,8 @@ public class Config {
@Getter private final Set<PropagationStyle> propagationStylesToExtract;
@Getter private final Set<PropagationStyle> propagationStylesToInject;
- @Getter private final String agentConfDPath;
@Getter private final boolean jmxFetchEnabled;
+ @Getter private final String jmxFetchConfigDir;
@Getter private final List<String> jmxFetchConfigs;
@Deprecated @Getter private final List<String> jmxFetchMetricsConfigs;
@Getter private final Integer jmxFetchCheckPeriod;
@@ -222,10 +222,10 @@ public class Config {
PropagationStyle.class,
true);
- agentConfDPath = getSettingFromEnvironment(AGENT_CONF_D, null);
jmxFetchEnabled =
getBooleanSettingFromEnvironment(JMX_FETCH_ENABLED, DEFAULT_JMX_FETCH_ENABLED);
- jmxFetchConfigs = getListSettingFromEnvironment(JMX_FETCH_CONFIGS, null);
+ jmxFetchConfigDir = getSettingFromEnvironment(JMX_FETCH_CONFIG_DIR, null);
+ jmxFetchConfigs = getListSettingFromEnvironment(JMX_FETCH_CONFIG, null);
jmxFetchMetricsConfigs = getListSettingFromEnvironment(JMX_FETCH_METRICS_CONFIGS, null);
jmxFetchCheckPeriod = getIntegerSettingFromEnvironment(JMX_FETCH_CHECK_PERIOD, null);
jmxFetchRefreshBeansPeriod =
@@ -304,10 +304,10 @@ public class Config {
? parent.propagationStylesToInject
: parsedPropagationStylesToInject;
- agentConfDPath = properties.getProperty(AGENT_CONF_D, parent.agentConfDPath);
jmxFetchEnabled =
getPropertyBooleanValue(properties, JMX_FETCH_ENABLED, parent.jmxFetchEnabled);
- jmxFetchConfigs = getPropertyListValue(properties, JMX_FETCH_CONFIGS, parent.jmxFetchConfigs);
+ jmxFetchConfigDir = properties.getProperty(JMX_FETCH_CONFIG_DIR, parent.jmxFetchConfigDir);
+ jmxFetchConfigs = getPropertyListValue(properties, JMX_FETCH_CONFIG, parent.jmxFetchConfigs);
jmxFetchMetricsConfigs =
getPropertyListValue(properties, JMX_FETCH_METRICS_CONFIGS, parent.jmxFetchMetricsConfigs);
jmxFetchCheckPeriod =
@@ -334,7 +334,7 @@ public class Config {
final Map<String, String> result = new HashMap<>(runtimeTags);
if (reportHostName) {
- String hostName = getHostName();
+ final String hostName = getHostName();
if (null != hostName && !hostName.isEmpty()) {
result.put(INTERNAL_HOST_NAME, hostName);
}
@@ -399,6 +399,23 @@ public class Config {
return anyEnabled;
}
+ public static boolean jmxFetchIntegrationEnabled(
+ final SortedSet<String> integrationNames, final boolean defaultEnabled) {
+ // If default is enabled, we want to enable individually,
+ // if default is disabled, we want to disable individually.
+ boolean anyEnabled = defaultEnabled;
+ for (final String name : integrationNames) {
+ final boolean configEnabled =
+ getBooleanSettingFromEnvironment("jmxfetch." + name + ".enabled", defaultEnabled);
+ if (defaultEnabled) {
+ anyEnabled &= configEnabled;
+ } else {
+ anyEnabled |= configEnabled;
+ }
+ }
+ return anyEnabled;
+ }
+
public static boolean traceAnalyticsIntegrationEnabled(
final SortedSet<String> integrationNames, final boolean defaultEnabled) {
// If default is enabled, we want to enable individually,
@@ -682,7 +699,7 @@ public class Config {
private String getHostName() {
try {
return InetAddress.getLocalHost().getHostName();
- } catch (UnknownHostException e) {
+ } catch (final UnknownHostException e) {
// If we are not able to detect the hostname we do not throw an exception.
}

MODIFY
dd-trace-api/src/test/groovy/datadog/trace/api/ConfigTest.groovy
dd-trace-api/src/test/groovy/datadog/trace/api/ConfigTest.groovy
@@ -35,8 +35,8 @@ import static datadog.trace.api.Config.SERVICE_MAPPING
import static datadog.trace.api.Config.SERVICE_NAME
import static datadog.trace.api.Config.SPAN_TAGS
import static datadog.trace.api.Config.TRACE_AGENT_PORT
-import static datadog.trace.api.Config.TRACE_REPORT_HOSTNAME
import static datadog.trace.api.Config.TRACE_ENABLED
+import static datadog.trace.api.Config.TRACE_REPORT_HOSTNAME
import static datadog.trace.api.Config.TRACE_RESOLVER_ENABLED
import static datadog.trace.api.Config.WRITER_TYPE
@@ -478,6 +478,40 @@ class ConfigTest extends Specification {
integrationNames = new TreeSet<>(names)
}
+ def "verify integration jmxfetch config"() {
+ setup:
+ environmentVariables.set("DD_JMXFETCH_ORDER_ENABLED", "false")
+ environmentVariables.set("DD_JMXFETCH_TEST_ENV_ENABLED", "true")
+ environmentVariables.set("DD_JMXFETCH_DISABLED_ENV_ENABLED", "false")
+
+ System.setProperty("dd.jmxfetch.order.enabled", "true")
+ System.setProperty("dd.jmxfetch.test-prop.enabled", "true")
+ System.setProperty("dd.jmxfetch.disabled-prop.enabled", "false")
+
+ expect:
+ Config.jmxFetchIntegrationEnabled(integrationNames, defaultEnabled) == expected
+
+ where:
+ names | defaultEnabled | expected
+ [] | true | true
+ [] | false | false
+ ["invalid"] | true | true
+ ["invalid"] | false | false
+ ["test-prop"] | false | true
+ ["test-env"] | false | true
+ ["disabled-prop"] | true | false
+ ["disabled-env"] | true | false
+ ["other", "test-prop"] | false | true
+ ["other", "test-env"] | false | true
+ ["order"] | false | true
+ ["test-prop", "disabled-prop"] | false | true
+ ["disabled-env", "test-env"] | false | true
+ ["test-prop", "disabled-prop"] | true | false
+ ["disabled-env", "test-env"] | true | false
+
+ integrationNames = new TreeSet<>(names)
+ }
+
def "verify integration trace analytics config"() {
setup:
environmentVariables.set("DD_ORDER_ANALYTICS_ENABLED", "false")

Change JMXFetch config keys

`agent.conf.d` -> `jmxfetch.config.dir`
`jmxfetch.configs` -> `jmxfetch.config`

Enabling bundled JMXFetch configs:
`dd.integration.<integration>.enabled=true` -> `dd.jmxfetch.<integration>.enabled=true`