Use jmx AppConfig Builder instead of factory method
Expose new options for configuring JMXFetch with standard datadog-agent config files with `jvm_direct: true` set as an instance attribute (this will be ignored by the datadog-agent). For Example: * `dd.agent.conf.d=/opt/datadog-agent/etc/conf.d` * `dd.jmxfetch.configs=activemq.d/conf.yaml,jmx.d/conf.yaml` will load jmx configs in those two files that have `jvm_direct: true` in their `instance` setup. Environment variables can also be used: `DD_AGENT_CONF_D` and `DD_JMXFETCH_CONFIGS` Depends on https://github.com/DataDog/jmxfetch/releases/tag/0.29.0 being released.
This commit is contained in:
parent
204b7cdd4c
commit
b505c60543
|
@ -4,7 +4,10 @@ plugins {
|
||||||
apply from: "${rootDir}/gradle/java.gradle"
|
apply from: "${rootDir}/gradle/java.gradle"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'com.datadoghq:jmxfetch:0.27.0'
|
compile('com.datadoghq:jmxfetch:0.29.0'){
|
||||||
|
exclude group: 'org.slf4j', module: 'slf4j-log4j12'
|
||||||
|
exclude group: 'log4j', module: 'log4j'
|
||||||
|
}
|
||||||
compile deps.slf4j
|
compile deps.slf4j
|
||||||
compile project(':dd-trace-api')
|
compile project(':dd-trace-api')
|
||||||
}
|
}
|
||||||
|
@ -32,12 +35,16 @@ tasks.register("submodulesUpdate", Exec) {
|
||||||
group 'Build Setup'
|
group 'Build Setup'
|
||||||
description 'Initializes and updates integrations-core git submodule'
|
description 'Initializes and updates integrations-core git submodule'
|
||||||
commandLine 'git', 'submodule', 'update', '--init', 'integrations-core'
|
commandLine 'git', 'submodule', 'update', '--init', 'integrations-core'
|
||||||
|
inputs.file file("${project.rootDir}/.git/modules/dd-java-agent/agent-jmxfetch/integrations-core/HEAD")
|
||||||
|
outputs.dir file("$projectDir/integrations-core")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.register("copyMetricConfigs", Exec) {
|
tasks.register("copyMetricConfigs", Exec) {
|
||||||
group 'Build Setup'
|
group 'Build Setup'
|
||||||
description 'Copy metrics.yaml files from integrations-core into resources'
|
description 'Copy metrics.yaml files from integrations-core into resources'
|
||||||
commandLine './copy-metric-configs.sh', 'integrations-core', sourceSets.main.output.resourcesDir
|
commandLine './copy-metric-configs.sh', 'integrations-core', sourceSets.main.output.resourcesDir
|
||||||
|
inputs.dir file("$projectDir/integrations-core")
|
||||||
|
outputs.dir sourceSets.main.output.resourcesDir
|
||||||
doFirst {
|
doFirst {
|
||||||
// Ensure the resources directory is available.
|
// Ensure the resources directory is available.
|
||||||
file(sourceSets.main.output.resourcesDir).mkdirs()
|
file(sourceSets.main.output.resourcesDir).mkdirs()
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package datadog.trace.agent.jmxfetch;
|
package datadog.trace.agent.jmxfetch;
|
||||||
|
|
||||||
|
import static org.datadog.jmxfetch.AppConfig.ACTION_COLLECT;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import datadog.trace.api.Config;
|
import datadog.trace.api.Config;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -16,6 +18,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.datadog.jmxfetch.App;
|
import org.datadog.jmxfetch.App;
|
||||||
import org.datadog.jmxfetch.AppConfig;
|
import org.datadog.jmxfetch.AppConfig;
|
||||||
|
import org.datadog.jmxfetch.reporter.ReporterFactory;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class JMXFetch {
|
public class JMXFetch {
|
||||||
|
@ -38,6 +41,14 @@ public class JMXFetch {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!log.isDebugEnabled()
|
||||||
|
&& System.getProperty("org.slf4j.simpleLogger.log.org.datadog.jmxfetch") == null) {
|
||||||
|
// Reduce noisiness of jmxfetch logging.
|
||||||
|
System.setProperty("org.slf4j.simpleLogger.log.org.datadog.jmxfetch", "warn");
|
||||||
|
}
|
||||||
|
|
||||||
|
final String agentConfDPath = config.getAgentConfDPath();
|
||||||
|
final List<String> jmxFetchConfigs = config.getJmxFetchConfigs();
|
||||||
final List<String> internalMetricsConfigs = getInternalMetricFiles();
|
final List<String> internalMetricsConfigs = getInternalMetricFiles();
|
||||||
final List<String> metricsConfigs = config.getJmxFetchMetricsConfigs();
|
final List<String> metricsConfigs = config.getJmxFetchMetricsConfigs();
|
||||||
final Integer checkPeriod = config.getJmxFetchCheckPeriod();
|
final Integer checkPeriod = config.getJmxFetchCheckPeriod();
|
||||||
|
@ -48,7 +59,9 @@ public class JMXFetch {
|
||||||
final String logLevel = getLogLevel();
|
final String logLevel = getLogLevel();
|
||||||
|
|
||||||
log.info(
|
log.info(
|
||||||
"JMXFetch config: {} {} {} {} {} {} {} {}",
|
"JMXFetch config: {} {} {} {} {} {} {} {} {} {}",
|
||||||
|
agentConfDPath,
|
||||||
|
jmxFetchConfigs,
|
||||||
internalMetricsConfigs,
|
internalMetricsConfigs,
|
||||||
metricsConfigs,
|
metricsConfigs,
|
||||||
checkPeriod,
|
checkPeriod,
|
||||||
|
@ -57,17 +70,24 @@ public class JMXFetch {
|
||||||
reporter,
|
reporter,
|
||||||
logLocation,
|
logLocation,
|
||||||
logLevel);
|
logLevel);
|
||||||
final AppConfig appConfig =
|
|
||||||
AppConfig.create(
|
final AppConfig.AppConfigBuilder configBuilder =
|
||||||
DEFAULT_CONFIGS,
|
AppConfig.builder()
|
||||||
internalMetricsConfigs,
|
.action(ImmutableList.of(ACTION_COLLECT))
|
||||||
metricsConfigs,
|
.confdDirectory(agentConfDPath)
|
||||||
checkPeriod,
|
.yamlFileList(jmxFetchConfigs)
|
||||||
refreshBeansPeriod,
|
.targetDirectInstances(true)
|
||||||
globalTags,
|
.instanceConfigResources(DEFAULT_CONFIGS)
|
||||||
reporter,
|
.metricConfigResources(internalMetricsConfigs)
|
||||||
logLocation,
|
.metricConfigFiles(metricsConfigs)
|
||||||
logLevel);
|
.refreshBeansPeriod(refreshBeansPeriod)
|
||||||
|
.globalTags(globalTags)
|
||||||
|
.reporter(ReporterFactory.getReporter(reporter));
|
||||||
|
|
||||||
|
if (checkPeriod != null) {
|
||||||
|
configBuilder.checkPeriod(checkPeriod);
|
||||||
|
}
|
||||||
|
final AppConfig appConfig = configBuilder.build();
|
||||||
|
|
||||||
final Thread thread =
|
final Thread thread =
|
||||||
new Thread(
|
new Thread(
|
||||||
|
|
|
@ -3,6 +3,6 @@ init_config:
|
||||||
new_gc_metrics: true
|
new_gc_metrics: true
|
||||||
|
|
||||||
instances:
|
instances:
|
||||||
- jmx_url: service:jmx:local:///
|
- jvm_direct: true
|
||||||
conf:
|
name: dd-java-agent default
|
||||||
# Intentionally left empty for now
|
conf: [] # Intentionally left empty for now
|
||||||
|
|
|
@ -64,7 +64,9 @@ public class Config {
|
||||||
public static final String PROPAGATION_STYLE_EXTRACT = "propagation.style.extract";
|
public static final String PROPAGATION_STYLE_EXTRACT = "propagation.style.extract";
|
||||||
public static final String PROPAGATION_STYLE_INJECT = "propagation.style.inject";
|
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_ENABLED = "jmxfetch.enabled";
|
||||||
|
public static final String JMX_FETCH_CONFIGS = "jmxfetch.configs";
|
||||||
public static final String JMX_FETCH_METRICS_CONFIGS = "jmxfetch.metrics-configs";
|
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_CHECK_PERIOD = "jmxfetch.check-period";
|
||||||
public static final String JMX_FETCH_REFRESH_BEANS_PERIOD = "jmxfetch.refresh-beans-period";
|
public static final String JMX_FETCH_REFRESH_BEANS_PERIOD = "jmxfetch.refresh-beans-period";
|
||||||
|
@ -146,8 +148,10 @@ public class Config {
|
||||||
@Getter private final Set<PropagationStyle> propagationStylesToExtract;
|
@Getter private final Set<PropagationStyle> propagationStylesToExtract;
|
||||||
@Getter private final Set<PropagationStyle> propagationStylesToInject;
|
@Getter private final Set<PropagationStyle> propagationStylesToInject;
|
||||||
|
|
||||||
|
@Getter private final String agentConfDPath;
|
||||||
@Getter private final boolean jmxFetchEnabled;
|
@Getter private final boolean jmxFetchEnabled;
|
||||||
@Getter private final List<String> jmxFetchMetricsConfigs;
|
@Getter private final List<String> jmxFetchConfigs;
|
||||||
|
@Deprecated @Getter private final List<String> jmxFetchMetricsConfigs;
|
||||||
@Getter private final Integer jmxFetchCheckPeriod;
|
@Getter private final Integer jmxFetchCheckPeriod;
|
||||||
@Getter private final Integer jmxFetchRefreshBeansPeriod;
|
@Getter private final Integer jmxFetchRefreshBeansPeriod;
|
||||||
@Getter private final String jmxFetchStatsdHost;
|
@Getter private final String jmxFetchStatsdHost;
|
||||||
|
@ -218,8 +222,10 @@ public class Config {
|
||||||
PropagationStyle.class,
|
PropagationStyle.class,
|
||||||
true);
|
true);
|
||||||
|
|
||||||
|
agentConfDPath = getSettingFromEnvironment(AGENT_CONF_D, null);
|
||||||
jmxFetchEnabled =
|
jmxFetchEnabled =
|
||||||
getBooleanSettingFromEnvironment(JMX_FETCH_ENABLED, DEFAULT_JMX_FETCH_ENABLED);
|
getBooleanSettingFromEnvironment(JMX_FETCH_ENABLED, DEFAULT_JMX_FETCH_ENABLED);
|
||||||
|
jmxFetchConfigs = getListSettingFromEnvironment(JMX_FETCH_CONFIGS, null);
|
||||||
jmxFetchMetricsConfigs = getListSettingFromEnvironment(JMX_FETCH_METRICS_CONFIGS, null);
|
jmxFetchMetricsConfigs = getListSettingFromEnvironment(JMX_FETCH_METRICS_CONFIGS, null);
|
||||||
jmxFetchCheckPeriod = getIntegerSettingFromEnvironment(JMX_FETCH_CHECK_PERIOD, null);
|
jmxFetchCheckPeriod = getIntegerSettingFromEnvironment(JMX_FETCH_CHECK_PERIOD, null);
|
||||||
jmxFetchRefreshBeansPeriod =
|
jmxFetchRefreshBeansPeriod =
|
||||||
|
@ -298,8 +304,10 @@ public class Config {
|
||||||
? parent.propagationStylesToInject
|
? parent.propagationStylesToInject
|
||||||
: parsedPropagationStylesToInject;
|
: parsedPropagationStylesToInject;
|
||||||
|
|
||||||
|
agentConfDPath = properties.getProperty(AGENT_CONF_D, parent.agentConfDPath);
|
||||||
jmxFetchEnabled =
|
jmxFetchEnabled =
|
||||||
getPropertyBooleanValue(properties, JMX_FETCH_ENABLED, parent.jmxFetchEnabled);
|
getPropertyBooleanValue(properties, JMX_FETCH_ENABLED, parent.jmxFetchEnabled);
|
||||||
|
jmxFetchConfigs = getPropertyListValue(properties, JMX_FETCH_CONFIGS, parent.jmxFetchConfigs);
|
||||||
jmxFetchMetricsConfigs =
|
jmxFetchMetricsConfigs =
|
||||||
getPropertyListValue(properties, JMX_FETCH_METRICS_CONFIGS, parent.jmxFetchMetricsConfigs);
|
getPropertyListValue(properties, JMX_FETCH_METRICS_CONFIGS, parent.jmxFetchMetricsConfigs);
|
||||||
jmxFetchCheckPeriod =
|
jmxFetchCheckPeriod =
|
||||||
|
|
Loading…
Reference in New Issue