Add option to disable JMXFetch
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
@@ -18,6 +18,11 @@ public class JMXFetch {
public static final void run() {
+ if (!Config.get().isJmxFetchEnabled()) {
+ log.info("JMXFetch is disabled");
+ return;
+ }
+
final List<String> metricsConfigs = Config.get().getJmxFetchMetricsConfigs();
final Integer checkPeriod = Config.get().getJmxFetchCheckPeriod();
final Integer refreshBeansPeriod = Config.get().getJmxFetchRefreshBeansPeriod();

MODIFY
dd-trace-api/src/main/java/datadog/trace/api/Config.java
dd-trace-api/src/main/java/datadog/trace/api/Config.java
@@ -36,6 +36,7 @@ public class Config {
public static final String SERVICE_MAPPING = "service.mapping";
public static final String SPAN_TAGS = "trace.span.tags";
public static final String HEADER_TAGS = "trace.header.tags";
+ public static final String JMX_FETCH_ENABLED = "jmxfetch.enabled";
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";
@@ -52,6 +53,7 @@ public class Config {
private static final boolean DEFAULT_PRIORITY_SAMPLING_ENABLED = false;
private static final boolean DEFAULT_TRACE_RESOLVER_ENABLED = true;
+ private static final boolean DEFAULT_JMX_FETCH_ENABLED = false;
@Getter private final String serviceName;
@Getter private final String writerType;
@@ -62,6 +64,7 @@ public class Config {
@Getter private final Map<String, String> serviceMapping;
@Getter private final Map<String, String> spanTags;
@Getter private final Map<String, String> headerTags;
+ @Getter private final boolean jmxFetchEnabled;
@Getter private final List<String> jmxFetchMetricsConfigs;
@Getter private final Integer jmxFetchCheckPeriod;
@Getter private final Integer jmxFetchRefreshBeansPeriod;
@@ -81,6 +84,8 @@ public class Config {
serviceMapping = getMapSettingFromEnvironment(SERVICE_MAPPING, null);
spanTags = getMapSettingFromEnvironment(SPAN_TAGS, null);
headerTags = getMapSettingFromEnvironment(HEADER_TAGS, null);
+ jmxFetchEnabled =
+ getBooleanSettingFromEnvironment(JMX_FETCH_ENABLED, DEFAULT_JMX_FETCH_ENABLED);
jmxFetchMetricsConfigs = getListSettingFromEnvironment(JMX_FETCH_METRICS_CONFIGS, null);
jmxFetchCheckPeriod = getIntegerSettingFromEnvironment(JMX_FETCH_CHECK_PERIOD, null);
jmxFetchRefreshBeansPeriod =
@@ -101,6 +106,8 @@ public class Config {
serviceMapping = getPropertyMapValue(properties, SERVICE_MAPPING, parent.serviceMapping);
spanTags = getPropertyMapValue(properties, SPAN_TAGS, parent.spanTags);
headerTags = getPropertyMapValue(properties, HEADER_TAGS, parent.headerTags);
+ jmxFetchEnabled =
+ getPropertyBooleanValue(properties, JMX_FETCH_ENABLED, parent.jmxFetchEnabled);
jmxFetchMetricsConfigs =
getPropertyListValue(properties, JMX_FETCH_METRICS_CONFIGS, parent.jmxFetchMetricsConfigs);
jmxFetchCheckPeriod =

MODIFY
dd-trace-api/src/test/groovy/datadog/trace/api/ConfigTest.groovy
dd-trace-api/src/test/groovy/datadog/trace/api/ConfigTest.groovy
@@ -14,6 +14,7 @@ import static Config.SERVICE_NAME
import static Config.SPAN_TAGS
import static Config.WRITER_TYPE
import static datadog.trace.api.Config.JMX_FETCH_CHECK_PERIOD
+import static datadog.trace.api.Config.JMX_FETCH_ENABLED
import static datadog.trace.api.Config.JMX_FETCH_METRICS_CONFIGS
import static datadog.trace.api.Config.JMX_FETCH_REFRESH_BEANS_PERIOD
import static datadog.trace.api.Config.JMX_FETCH_REPORTER
@@ -46,6 +47,7 @@ class ConfigTest extends Specification {
config.serviceMapping == [:]
config.spanTags == [:]
config.headerTags == [:]
+ config.jmxFetchEnabled == false
config.jmxFetchMetricsConfigs == []
config.jmxFetchCheckPeriod == null
config.jmxFetchRefreshBeansPeriod == null
@@ -64,6 +66,7 @@ class ConfigTest extends Specification {
System.setProperty(PREFIX + SERVICE_MAPPING, "a:1")
System.setProperty(PREFIX + SPAN_TAGS, "b:2")
System.setProperty(PREFIX + HEADER_TAGS, "c:3")
+ System.setProperty(PREFIX + JMX_FETCH_ENABLED, "true")
System.setProperty(PREFIX + JMX_FETCH_METRICS_CONFIGS, "/foo.yaml,/bar.yaml")
System.setProperty(PREFIX + JMX_FETCH_CHECK_PERIOD, "100")
System.setProperty(PREFIX + JMX_FETCH_REFRESH_BEANS_PERIOD, "200")
@@ -82,6 +85,7 @@ class ConfigTest extends Specification {
config.serviceMapping == [a: "1"]
config.spanTags == [b: "2"]
config.headerTags == [c: "3"]
+ config.jmxFetchEnabled == true
config.jmxFetchMetricsConfigs == ["/foo.yaml", "/bar.yaml"]
config.jmxFetchCheckPeriod == 100
config.jmxFetchRefreshBeansPeriod == 200

Add option to disable JMXFetch