Adding configuration variables needed for StatsD metric support
MODIFY
dd-trace-api/src/main/java/datadog/trace/api/Config.java
dd-trace-api/src/main/java/datadog/trace/api/Config.java
@@ -87,6 +87,10 @@ public class Config {
public static final String JMX_FETCH_STATSD_HOST = "jmxfetch.statsd.host";
public static final String JMX_FETCH_STATSD_PORT = "jmxfetch.statsd.port";
+ public static final String HEALTH_METRICS_ENABLED = "trace.health.metrics.enabled";
+ public static final String HEALTH_METRICS_STATSD_HOST = "trace.health.metrics.statsd.host";
+ public static final String HEALTH_METRICS_STATSD_PORT = "trace.health.metrics.statsd.port";
+
public static final String LOGS_INJECTION_ENABLED = "logs.injection";
public static final String SERVICE_TAG = "service";
@@ -127,6 +131,9 @@ public class Config {
public static final int DEFAULT_JMX_FETCH_STATSD_PORT = 8125;
+ public static final boolean DEFAULT_METRICS_ENABLED = false;
+ // No default constants for metrics statsd support -- falls back to jmx fetch values
+
public static final boolean DEFAULT_LOGS_INJECTION_ENABLED = false;
private static final String SPLIT_BY_SPACE_OR_COMMA_REGEX = "[,\\s]+";
@@ -190,6 +197,11 @@ public class Config {
@Getter private final String jmxFetchStatsdHost;
@Getter private final Integer jmxFetchStatsdPort;
+ // These values are default-ed to those of jmx fetch values as needed
+ @Getter private final boolean healthMetricsEnabled;
+ @Getter private final String healthMetricsStatsdHost;
+ @Getter private final Integer healthMetricsStatsdPort;
+
@Getter private final boolean logsInjectionEnabled;
@Getter private final boolean reportHostName;
@@ -300,6 +312,12 @@ public class Config {
jmxFetchStatsdPort =
getIntegerSettingFromEnvironment(JMX_FETCH_STATSD_PORT, DEFAULT_JMX_FETCH_STATSD_PORT);
+ // Writer.Builder createMonitor will use the values of the JMX fetch & agent to fill-in defaults
+ healthMetricsEnabled =
+ getBooleanSettingFromEnvironment(HEALTH_METRICS_ENABLED, DEFAULT_METRICS_ENABLED);
+ healthMetricsStatsdHost = getSettingFromEnvironment(HEALTH_METRICS_STATSD_HOST, null);
+ healthMetricsStatsdPort = getIntegerSettingFromEnvironment(HEALTH_METRICS_STATSD_PORT, null);
+
logsInjectionEnabled =
getBooleanSettingFromEnvironment(LOGS_INJECTION_ENABLED, DEFAULT_LOGS_INJECTION_ENABLED);
@@ -417,6 +435,14 @@ public class Config {
jmxFetchStatsdPort =
getPropertyIntegerValue(properties, JMX_FETCH_STATSD_PORT, parent.jmxFetchStatsdPort);
+ healthMetricsEnabled =
+ getPropertyBooleanValue(properties, HEALTH_METRICS_ENABLED, DEFAULT_METRICS_ENABLED);
+ healthMetricsStatsdHost =
+ properties.getProperty(HEALTH_METRICS_STATSD_HOST, parent.healthMetricsStatsdHost);
+ healthMetricsStatsdPort =
+ getPropertyIntegerValue(
+ properties, HEALTH_METRICS_STATSD_PORT, parent.healthMetricsStatsdPort);
+
logsInjectionEnabled =
getBooleanSettingFromEnvironment(LOGS_INJECTION_ENABLED, DEFAULT_LOGS_INJECTION_ENABLED);

MODIFY
dd-trace-api/src/test/groovy/datadog/trace/api/ConfigTest.groovy
dd-trace-api/src/test/groovy/datadog/trace/api/ConfigTest.groovy
@@ -40,6 +40,9 @@ 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
+import static datadog.trace.api.Config.HEALTH_METRICS_ENABLED
+import static datadog.trace.api.Config.HEALTH_METRICS_STATSD_HOST
+import static datadog.trace.api.Config.HEALTH_METRICS_STATSD_PORT
class ConfigTest extends DDSpecification {
@Rule
@@ -93,6 +96,9 @@ class ConfigTest extends DDSpecification {
config.jmxFetchRefreshBeansPeriod == null
config.jmxFetchStatsdHost == null
config.jmxFetchStatsdPort == DEFAULT_JMX_FETCH_STATSD_PORT
+ config.healthMetricsEnabled == false
+ config.healthMetricsStatsdHost == null
+ config.healthMetricsStatsdPort == null
config.toString().contains("unnamed-java-app")
where:
@@ -136,6 +142,9 @@ class ConfigTest extends DDSpecification {
prop.setProperty(JMX_FETCH_REFRESH_BEANS_PERIOD, "200")
prop.setProperty(JMX_FETCH_STATSD_HOST, "statsd host")
prop.setProperty(JMX_FETCH_STATSD_PORT, "321")
+ prop.setProperty(HEALTH_METRICS_ENABLED, "true")
+ prop.setProperty(HEALTH_METRICS_STATSD_HOST, "metrics statsd host")
+ prop.setProperty(HEALTH_METRICS_STATSD_PORT, "654")
when:
Config config = Config.get(prop)
@@ -169,6 +178,9 @@ class ConfigTest extends DDSpecification {
config.jmxFetchRefreshBeansPeriod == 200
config.jmxFetchStatsdHost == "statsd host"
config.jmxFetchStatsdPort == 321
+ config.healthMetricsEnabled == true
+ config.healthMetricsStatsdHost == "metrics statsd host"
+ config.healthMetricsStatsdPort == 654
}
def "specify overrides via system properties"() {
@@ -203,6 +215,9 @@ class ConfigTest extends DDSpecification {
System.setProperty(PREFIX + JMX_FETCH_REFRESH_BEANS_PERIOD, "200")
System.setProperty(PREFIX + JMX_FETCH_STATSD_HOST, "statsd host")
System.setProperty(PREFIX + JMX_FETCH_STATSD_PORT, "321")
+ System.setProperty(PREFIX + HEALTH_METRICS_ENABLED, "true")
+ System.setProperty(PREFIX + HEALTH_METRICS_STATSD_HOST, "metrics statsd host")
+ System.setProperty(PREFIX + HEALTH_METRICS_STATSD_PORT, "654")
when:
Config config = new Config()
@@ -236,6 +251,9 @@ class ConfigTest extends DDSpecification {
config.jmxFetchRefreshBeansPeriod == 200
config.jmxFetchStatsdHost == "statsd host"
config.jmxFetchStatsdPort == 321
+ config.healthMetricsEnabled == true
+ config.healthMetricsStatsdHost == "metrics statsd host"
+ config.healthMetricsStatsdPort == 654
}
def "specify overrides via env vars"() {

Adding configuration variables needed for StatsD metric support