Remove jmxfetch module (#13)

This commit is contained in:
Trask Stalnaker 2019-11-18 17:24:37 -08:00 committed by GitHub
parent 88b25dca82
commit d86632d648
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 14 additions and 908 deletions

3
.gitmodules vendored
View File

@ -1,3 +0,0 @@
[submodule "dd-java-agent/agent-jmxfetch/integrations-core"]
path = dd-java-agent/agent-jmxfetch/integrations-core
url = https://github.com/DataDog/integrations-core.git

View File

@ -1,65 +0,0 @@
plugins {
id "com.github.johnrengelman.shadow"
}
apply from: "${rootDir}/gradle/java.gradle"
dependencies {
compile('com.datadoghq:jmxfetch:0.32.1') {
exclude group: 'org.slf4j', module: 'slf4j-log4j12'
exclude group: 'log4j', module: 'log4j'
}
compile deps.slf4j
compile project(':dd-trace-api')
}
configurations {
// exclude bootstrap dependencies from shadowJar
runtime.exclude module: deps.opentracing
runtime.exclude module: deps.slf4j
runtime.exclude group: 'org.slf4j'
runtime.exclude group: 'io.opentracing'
}
shadowJar {
dependencies {
exclude(project(':dd-java-agent:agent-bootstrap'))
exclude(project(':dd-trace-api'))
}
}
jar {
classifier = 'unbundled'
}
tasks.register("submodulesUpdate", Exec) {
group 'Build Setup'
description 'Initializes and updates integrations-core git submodule'
commandLine 'git', 'submodule', 'update', '--init', 'integrations-core'
def submoduleHead = file("${project.rootDir}/.git/modules/dd-java-agent/agent-jmxfetch/integrations-core/HEAD")
if (submoduleHead.exists()) {
inputs.file "${project.rootDir}/.git/modules/dd-java-agent/agent-jmxfetch/integrations-core/HEAD"
}
def integrationsCore = file("$projectDir/integrations-core")
outputs.dir integrationsCore
if (integrationsCore.list().length == 0) {
outputs.upToDateWhen { false }
}
}
tasks.register("copyMetricConfigs", Exec) {
group 'Build Setup'
description 'Copy metrics.yaml files from integrations-core into resources'
commandLine './copy-metric-configs.sh', 'integrations-core', sourceSets.main.output.resourcesDir
inputs.dir file("$projectDir/integrations-core")
outputs.dir sourceSets.main.output.resourcesDir
doFirst {
// Ensure the resources directory is available.
file(sourceSets.main.output.resourcesDir).mkdirs()
}
}
copyMetricConfigs.dependsOn submodulesUpdate
processResources.finalizedBy copyMetricConfigs
copyMetricConfigs.mustRunAfter processResources
// In CI, there seems to be a race condition where processResources overwrites the copied metric config files.
// Ensure that task runs last to avoid this problem.

View File

@ -1,54 +0,0 @@
#!/usr/bin/env bash
# Exit on error:
set -e
# Debug mode:
set -x
function print_usage() {
echo "Usage: $0 search_directory build_resources_output_directory"
}
search_directory=$1
if [ ! -d "$search_directory" ]; then
echo "Must specify a valid search_directory"
print_usage
exit 1
fi
build_resources_output_directory=$2
if [ ! -d "$build_resources_output_directory" ]; then
echo "Must specify a valid build_resources_output_directory"
print_usage
exit 1
fi
# Add the full package path.
build_resources_output_directory="$build_resources_output_directory/datadog/trace/agent/jmxfetch"
# Find all the metrics.yaml files containing "jmx_metrics:"
metrics_files=$(grep --include=metrics.yaml -rwl $search_directory -e 'jmx_metrics:')
if [ -z "$metrics_files" ]; then
echo "No metrics.yaml files with jmx_metrics blocks found."
print_usage
exit 1
fi
# reset file and ensure directories exists
mkdir -p $build_resources_output_directory/metricconfigs
> $build_resources_output_directory/metricconfigs.txt
for input_file in $metrics_files ; do
# generate new name based on integration folder name which should look like this:
# integrations-core/<integration_name>/datadog_checks/<integration_name>/data/metrics.yaml
output_file=$(echo "$input_file" | awk -F/ '{print $2}')
# save file name in metricconfigs.txt
echo "$output_file.yaml" >> $build_resources_output_directory/metricconfigs.txt
# copy to output location
output_file="$build_resources_output_directory/metricconfigs/$output_file.yaml"
cp $input_file $output_file
done

@ -1 +0,0 @@
Subproject commit dc34f01fba5edb4982169085c4906cd8539ea313

View File

@ -1,184 +0,0 @@
package datadog.trace.agent.jmxfetch;
import static org.datadog.jmxfetch.AppConfig.ACTION_COLLECT;
import com.google.common.collect.ImmutableList;
import datadog.trace.api.Config;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.SortedSet;
import java.util.TreeSet;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.datadog.jmxfetch.App;
import org.datadog.jmxfetch.AppConfig;
import org.datadog.jmxfetch.reporter.ReporterFactory;
@Slf4j
public class JMXFetch {
public static final ImmutableList<String> DEFAULT_CONFIGS =
ImmutableList.of("jmxfetch-config.yaml");
private static final int SLEEP_AFTER_JMXFETCH_EXITS = 5000;
private static final String UNIX_DOMAIN_SOCKET_PREFIX = "unix://";
public static final void run() {
run(Config.get());
}
// This is used by tests
private static void run(final Config config) {
if (!config.isJmxFetchEnabled()) {
log.info("JMXFetch is disabled");
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 jmxFetchConfigDir = config.getJmxFetchConfigDir();
final List<String> jmxFetchConfigs = config.getJmxFetchConfigs();
final List<String> internalMetricsConfigs = getInternalMetricFiles();
final List<String> metricsConfigs = config.getJmxFetchMetricsConfigs();
final Integer checkPeriod = config.getJmxFetchCheckPeriod();
final Integer refreshBeansPeriod = config.getJmxFetchRefreshBeansPeriod();
final Map<String, String> globalTags = config.getMergedJmxTags();
final String reporter = getReporter(config);
final String logLocation = getLogLocation();
final String logLevel = getLogLevel();
log.info(
"JMXFetch config: {} {} {} {} {} {} {} {} {} {}",
jmxFetchConfigDir,
jmxFetchConfigs,
internalMetricsConfigs,
metricsConfigs,
checkPeriod,
refreshBeansPeriod,
globalTags,
reporter,
logLocation,
logLevel);
final AppConfig.AppConfigBuilder configBuilder =
AppConfig.builder()
.action(ImmutableList.of(ACTION_COLLECT))
// App should be run as daemon otherwise CLI apps would not exit once main method exits.
.daemon(true)
.confdDirectory(jmxFetchConfigDir)
.yamlFileList(jmxFetchConfigs)
.targetDirectInstances(true)
.instanceConfigResources(DEFAULT_CONFIGS)
.metricConfigResources(internalMetricsConfigs)
.metricConfigFiles(metricsConfigs)
.refreshBeansPeriod(refreshBeansPeriod)
.globalTags(globalTags)
.reporter(ReporterFactory.getReporter(reporter));
if (checkPeriod != null) {
configBuilder.checkPeriod(checkPeriod);
}
final AppConfig appConfig = configBuilder.build();
final Thread thread =
new Thread(
new Runnable() {
@Override
public void run() {
while (true) {
try {
final int result = App.run(appConfig);
log.error("jmx collector exited with result: " + result);
} catch (final Exception e) {
log.error("Exception in jmx collector thread", e);
}
try {
Thread.sleep(SLEEP_AFTER_JMXFETCH_EXITS);
} catch (final InterruptedException e) {
// It looks like JMXFetch itself eats up InterruptedException, so we will do
// same here for consistency
log.error("JMXFetch was interrupted, ignoring", e);
}
}
}
});
thread.setName("dd-jmx-collector");
thread.setDaemon(true);
thread.start();
}
private static String getReporter(final Config config) {
if (Config.LOGGING_WRITER_TYPE.equals(config.getWriterType())) {
// If logging writer is enabled then also enable console reporter in JMXFetch
return "console";
}
String host =
config.getJmxFetchStatsdHost() == null
? config.getAgentHost()
: config.getJmxFetchStatsdHost();
int port = config.getJmxFetchStatsdPort();
if (host.startsWith(UNIX_DOMAIN_SOCKET_PREFIX)) {
host = host.substring(UNIX_DOMAIN_SOCKET_PREFIX.length());
// Port equal to zero tells the java dogstatsd client to use UDS
port = 0;
}
return "statsd:" + host + ":" + port;
}
private static List<String> getInternalMetricFiles() {
try {
final InputStream metricConfigsStream =
JMXFetch.class.getResourceAsStream("metricconfigs.txt");
if (metricConfigsStream == null) {
log.debug("metricconfigs not found. returning empty set");
return Collections.emptyList();
} else {
final String configs = IOUtils.toString(metricConfigsStream, StandardCharsets.UTF_8);
final String[] split = configs.split("\n");
final List<String> result = new ArrayList<>(split.length);
final SortedSet<String> integrationName = new TreeSet<>();
for (final String config : split) {
integrationName.clear();
integrationName.add(config.replace(".yaml", ""));
if (Config.get().isJmxFetchIntegrationEnabled(integrationName, false)) {
final URL resource = JMXFetch.class.getResource("metricconfigs/" + config);
// jar!/ means a file internal to a jar, only add the part after if it exists
final String path = resource.getPath();
final int filenameIndex = path.indexOf("jar!/");
if (filenameIndex != -1) {
result.add(path.substring(filenameIndex + 5));
} else {
result.add(path.substring(1));
}
}
}
return result;
}
} catch (final IOException e) {
log.debug("error reading metricconfigs. returning empty set", e);
return Collections.emptyList();
}
}
private static String getLogLocation() {
return System.getProperty("org.slf4j.simpleLogger.logFile", "System.err");
}
private static String getLogLevel() {
return System.getProperty("org.slf4j.simpleLogger.defaultLogLevel", "info").toUpperCase();
}
}

View File

@ -1,8 +0,0 @@
# Metric Configs
Files from [integrations-core](https://github.com/DataDog/integrations-core/search?q=jmx_metrics&unscoped_q=jmx_metrics)
are copied here at build time by the `copy-metric-configs.sh` script which is called by gradle after initializing the submodule.
These are then bundled in `dd-java-agent.jar`. Due to limitations in Java, it is non-trivial
to get all these files from within the jar without knowing their names.
Consequently, we list out each integration in `metricconfigs.txt` so the agent can reference them.

View File

@ -1,8 +0,0 @@
init_config:
is_jmx: true
new_gc_metrics: true
instances:
- jvm_direct: true
name: dd-java-agent default
conf: [] # Intentionally left empty for now

View File

@ -55,7 +55,6 @@ def includeShadowJar(subproject, jarname) {
}
includeShadowJar(project(':dd-java-agent:instrumentation'), 'agent-tooling-and-instrumentation.isolated')
includeShadowJar(project(':dd-java-agent:agent-jmxfetch'), 'agent-jmxfetch.isolated')
jar {
classifier = 'unbundled'

View File

@ -34,7 +34,6 @@ public class TracingAgent {
// fields must be managed under class lock
private static ClassLoader AGENT_CLASSLOADER = null;
private static ClassLoader JMXFETCH_CLASSLOADER = null;
public static void premain(final String agentArgs, final Instrumentation inst) throws Exception {
agentmain(agentArgs, inst);
@ -47,49 +46,6 @@ public class TracingAgent {
final URL bootstrapURL = installBootstrapJar(inst);
startDatadogAgent(inst, bootstrapURL);
if (isAppUsingCustomLogManager()) {
System.out.println("Custom logger detected. Delaying JMXFetch initialization.");
/*
* java.util.logging.LogManager maintains a final static LogManager, which is created during class initialization.
*
* JMXFetch uses jre bootstrap classes which touch this class. This means applications which require a custom log
* manager may not have a chance to set the global log manager if jmxfetch runs first. JMXFetch will incorrectly
* set the global log manager in cases where the app sets the log manager system property or when the log manager
* class is not on the system classpath.
*
* Our solution is to delay the initialization of jmxfetch when we detect a custom log manager being used.
*
* Once we see the LogManager class loading, it's safe to start jmxfetch because the application is already setting
* the global log manager and jmxfetch won't be able to touch it due to classloader locking.
*/
final Class<?> agentInstallerClass =
AGENT_CLASSLOADER.loadClass("datadog.trace.agent.tooling.AgentInstaller");
final Method registerCallbackMethod =
agentInstallerClass.getMethod("registerClassLoadCallback", String.class, Runnable.class);
registerCallbackMethod.invoke(
null, "java.util.logging.LogManager", new LoggingCallback(inst, bootstrapURL));
} else {
startJmxFetch(inst, bootstrapURL);
}
}
protected static class LoggingCallback implements Runnable {
private final Instrumentation inst;
private final URL bootstrapURL;
public LoggingCallback(final Instrumentation inst, final URL bootstrapURL) {
this.inst = inst;
this.bootstrapURL = bootstrapURL;
}
@Override
public void run() {
try {
startJmxFetch(inst, bootstrapURL);
} catch (final Exception e) {
throw new RuntimeException(e);
}
}
}
private static synchronized void startDatadogAgent(
@ -125,25 +81,6 @@ public class TracingAgent {
}
}
private static synchronized void startJmxFetch(final Instrumentation inst, final URL bootstrapURL)
throws Exception {
if (JMXFETCH_CLASSLOADER == null) {
final ClassLoader jmxFetchClassLoader =
createDatadogClassLoader("agent-jmxfetch.isolated", bootstrapURL);
final ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(jmxFetchClassLoader);
final Class<?> jmxFetchAgentClass =
jmxFetchClassLoader.loadClass("datadog.trace.agent.jmxfetch.JMXFetch");
final Method jmxFetchInstallerMethod = jmxFetchAgentClass.getMethod("run");
jmxFetchInstallerMethod.invoke(null);
JMXFETCH_CLASSLOADER = jmxFetchClassLoader;
} finally {
Thread.currentThread().setContextClassLoader(contextLoader);
}
}
}
private static void configureLogger() {
setSystemPropertyDefault(SIMPLE_LOGGER_SHOW_DATE_TIME_PROPERTY, "true");
setSystemPropertyDefault(
@ -314,66 +251,6 @@ public class TracingAgent {
return false;
}
/**
* Search for java or datadog-tracer sysprops which indicate that a custom log manager will be
* used. Also search for any app classes known to set a custom log manager.
*
* @return true if we detect a custom log manager being used.
*/
private static boolean isAppUsingCustomLogManager() {
boolean debugEnabled = false;
if (System.getProperty(SIMPLE_LOGGER_DEFAULT_LOG_LEVEL_PROPERTY) != null) {
debugEnabled =
"debug".equalsIgnoreCase(System.getProperty(SIMPLE_LOGGER_DEFAULT_LOG_LEVEL_PROPERTY));
} else {
debugEnabled = isDebugMode();
}
final String tracerCustomLogManSysprop = "dd.app.customlogmanager";
final String customLogManagerProp = System.getProperty(tracerCustomLogManSysprop);
final String customLogManagerEnv =
System.getenv(tracerCustomLogManSysprop.replace('.', '_').toUpperCase());
if (customLogManagerProp != null || customLogManagerEnv != null) {
if (debugEnabled) {
System.out.println("Prop - customlogmanager: " + customLogManagerProp);
System.out.println("Env - customlogmanager: " + customLogManagerEnv);
}
// Allow setting to skip these automatic checks:
return Boolean.parseBoolean(customLogManagerProp)
|| Boolean.parseBoolean(customLogManagerEnv);
}
final String jbossHome = System.getenv("JBOSS_HOME");
if (jbossHome != null) {
if (debugEnabled) {
System.out.println("Env - jboss: " + jbossHome);
}
// JBoss/Wildfly is known to set a custom log manager after startup.
// Originally we were checking for the presence of a jboss class,
// but it seems some non-jboss applications have jboss classes on the classpath.
// This would cause jmxfetch initialization to be delayed indefinitely.
// Checking for an environment variable required by jboss instead.
return true;
}
final String logManagerProp = System.getProperty("java.util.logging.manager");
if (logManagerProp != null) {
final boolean onSysClasspath =
ClassLoader.getSystemResource(logManagerProp.replaceAll("\\.", "/") + ".class") != null;
if (debugEnabled) {
System.out.println("Prop - logging.manager: " + logManagerProp);
System.out.println("logging.manager on system classpath: " + onSysClasspath);
}
// Some applications set java.util.logging.manager but never actually initialize the logger.
// Check to see if the configured manager is on the system classpath.
// If so, it should be safe to initialize jmxfetch which will setup the log manager.
return !onSysClasspath;
}
return false;
}
private static boolean isJavaBefore9() {
return System.getProperty("java.version").startsWith("1.");
}

View File

@ -1,69 +0,0 @@
package datadog.trace.agent
import datadog.trace.agent.test.IntegrationTestUtils
import jvmbootstraptest.LogManagerSetter
import spock.lang.Requires
import spock.lang.Retry
import spock.lang.Specification
import spock.lang.Timeout
// Note: this test is fails on IBM JVM, we would need to investigate this at some point
@Requires({ !System.getProperty("java.vm.name").contains("IBM J9 VM") })
@Retry
@Timeout(30)
class CustomLogManagerTest extends Specification {
// Run all tests using forked jvm because groovy has already set the global log manager
def "jmxfetch starts up in premain with no custom log manager set"() {
expect:
IntegrationTestUtils.runOnSeparateJvm(LogManagerSetter.getName()
, ["-Ddd.jmxfetch.enabled=true", "-Ddd.jmxfetch.refresh-beans-period=1", "-Ddatadog.slf4j.simpleLogger.defaultLogLevel=off"] as String[]
, "" as String[]
, [:]
, true) == 0
}
def "jmxfetch starts up in premain if configured log manager on system classpath"() {
expect:
IntegrationTestUtils.runOnSeparateJvm(LogManagerSetter.getName()
, ["-Ddd.jmxfetch.enabled=true", "-Ddd.jmxfetch.refresh-beans-period=1", "-Ddatadog.slf4j.simpleLogger.defaultLogLevel=off", "-Djava.util.logging.manager=jvmbootstraptest.CustomLogManager"] as String[]
, "" as String[]
, [:]
, true) == 0
}
def "jmxfetch startup is delayed with java.util.logging.manager sysprop"() {
expect:
IntegrationTestUtils.runOnSeparateJvm(LogManagerSetter.getName()
, ["-Ddd.jmxfetch.enabled=true", "-Ddd.jmxfetch.refresh-beans-period=1", "-Ddatadog.slf4j.simpleLogger.defaultLogLevel=off", "-Djava.util.logging.manager=jvmbootstraptest.MissingLogManager"] as String[]
, "" as String[]
, [:]
, true) == 0
}
def "jmxfetch startup delayed with tracer custom log manager setting"() {
expect:
IntegrationTestUtils.runOnSeparateJvm(LogManagerSetter.getName()
, ["-Ddd.jmxfetch.enabled=true", "-Ddd.jmxfetch.refresh-beans-period=1", "-Ddatadog.slf4j.simpleLogger.defaultLogLevel=off", "-Ddd.app.customlogmanager=true"] as String[]
, "" as String[]
, [:]
, true) == 0
}
def "jmxfetch startup delayed with JBOSS_HOME environment variable"() {
expect:
IntegrationTestUtils.runOnSeparateJvm(LogManagerSetter.getName()
, ["-Ddd.jmxfetch.enabled=true", "-Ddd.jmxfetch.refresh-beans-period=1", "-Ddatadog.slf4j.simpleLogger.defaultLogLevel=off", "-Ddd.app.customlogmanager=true"] as String[]
, "" as String[]
, ["JBOSS_HOME": "/"]
, true) == 0
}
def "jmxfetch startup in premain forced by customlogmanager=false"() {
expect:
IntegrationTestUtils.runOnSeparateJvm(LogManagerSetter.getName()
, ["-Ddd.jmxfetch.enabled=true", "-Ddd.jmxfetch.refresh-beans-period=1", "-Ddatadog.slf4j.simpleLogger.defaultLogLevel=off", "-Ddd.app.customlogmanager=false", "-Djava.util.logging.manager=jvmbootstraptest.CustomLogManager"] as String[]
, "" as String[]
, ["JBOSS_HOME": "/"]
, true) == 0
}
}

View File

@ -1,84 +0,0 @@
package datadog.trace.agent
import datadog.trace.agent.test.IntegrationTestUtils
import datadog.trace.api.Config
import org.junit.Rule
import org.junit.contrib.java.lang.system.RestoreSystemProperties
import spock.lang.Specification
import java.lang.reflect.Method
class JMXFetchTest extends Specification {
@Rule
public final RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties()
def "test jmxfetch"() {
setup:
def currentContextLoader = Thread.currentThread().getContextClassLoader()
DatagramSocket socket = new DatagramSocket(0)
System.properties.setProperty("dd.jmxfetch.enabled", "true")
System.properties.setProperty("dd.jmxfetch.statsd.port", Integer.toString(socket.localPort))
// Overwrite writer type to disable console jmxfetch reporter
System.properties.setProperty("dd.writer.type", "DDAgentWriter")
def classLoader = IntegrationTestUtils.getJmxFetchClassLoader()
// Have to set this so JMXFetch knows where to find resources
Thread.currentThread().setContextClassLoader(classLoader)
final Class<?> jmxFetchAgentClass =
classLoader.loadClass("datadog.trace.agent.jmxfetch.JMXFetch")
final Method jmxFetchInstallerMethod = jmxFetchAgentClass.getDeclaredMethod("run", Config)
jmxFetchInstallerMethod.setAccessible(true)
jmxFetchInstallerMethod.invoke(null, new Config())
byte[] buf = new byte[1500]
DatagramPacket packet = new DatagramPacket(buf, buf.length)
socket.receive(packet)
String received = new String(packet.getData(), 0, packet.getLength())
Set<String> threads = Thread.getAllStackTraces().keySet().collect { it.name }
expect:
threads.contains("dd-jmx-collector")
received.contains("jvm.")
cleanup:
jmxFetchInstallerMethod.setAccessible(false)
socket.close()
Thread.currentThread().setContextClassLoader(currentContextLoader)
}
def "test jmxfetch config"() {
setup:
names.each {
System.setProperty("dd.jmxfetch.${it}.enabled", "$enable")
}
def classLoader = IntegrationTestUtils.getJmxFetchClassLoader()
// Have to set this so JMXFetch knows where to find resources
Thread.currentThread().setContextClassLoader(classLoader)
final Class<?> jmxFetchAgentClass =
classLoader.loadClass("datadog.trace.agent.jmxfetch.JMXFetch")
final Method jmxFetchInstallerMethod = jmxFetchAgentClass.getDeclaredMethod("getInternalMetricFiles")
jmxFetchInstallerMethod.setAccessible(true)
expect:
jmxFetchInstallerMethod.invoke(null).sort() == result.sort()
cleanup:
names.each {
System.clearProperty("dd.integration.${it}.enabled")
}
where:
names | enable | result
[] | true | []
["tomcat"] | false | []
["tomcat"] | true | ["datadog/trace/agent/jmxfetch/metricconfigs/tomcat.yaml"]
["kafka"] | true | ["datadog/trace/agent/jmxfetch/metricconfigs/kafka.yaml"]
["tomcat", "kafka"] | true | ["datadog/trace/agent/jmxfetch/metricconfigs/tomcat.yaml", "datadog/trace/agent/jmxfetch/metricconfigs/kafka.yaml"]
["tomcat", "kafka"] | false | []
["invalid"] | true | []
}
}

View File

@ -17,7 +17,7 @@ class LogLevelTest extends Specification {
def "dd.trace.debug false"() {
expect:
IntegrationTestUtils.runOnSeparateJvm(LogLevelChecker.getName()
, ["-Ddd.trace.debug=false","-Ddd.jmxfetch.enabled=false","-Ddd.trace.enabled=false"] as String[]
, ["-Ddd.trace.debug=false","-Ddd.trace.enabled=false"] as String[]
, "" as String[]
, [:]
, true) == 1
@ -25,7 +25,7 @@ class LogLevelTest extends Specification {
def "SLF4J DEBUG && dd.trace.debug is false"() {
expect:
IntegrationTestUtils.runOnSeparateJvm(LogLevelChecker.getName()
, ["-Ddd.trace.debug=false","-Ddatadog.slf4j.simpleLogger.defaultLogLevel=debug","-Ddd.jmxfetch.enabled=false","-Ddd.trace.enabled=false"] as String[]
, ["-Ddd.trace.debug=false","-Ddatadog.slf4j.simpleLogger.defaultLogLevel=debug","-Ddd.trace.enabled=false"] as String[]
, "" as String[]
, [:]
, true) == 0
@ -33,7 +33,7 @@ class LogLevelTest extends Specification {
def "dd.trace.debug is false && DD_TRACE_DEBUG is true"() {
expect:
IntegrationTestUtils.runOnSeparateJvm(LogLevelChecker.getName()
, ["-Ddd.trace.debug=false","-Ddd.jmxfetch.enabled=false","-Ddd.trace.enabled=false"] as String[]
, ["-Ddd.trace.debug=false","-Ddd.trace.enabled=false"] as String[]
, "" as String[]
, ["DD_TRACE_DEBUG": "true"]
, true) == 1
@ -42,7 +42,7 @@ class LogLevelTest extends Specification {
def "dd.trace.debug is true"() {
expect:
IntegrationTestUtils.runOnSeparateJvm(LogLevelChecker.getName()
, ["-Ddd.trace.debug=true","-Ddd.jmxfetch.enabled=false","-Ddd.trace.enabled=false"] as String[]
, ["-Ddd.trace.debug=true","-Ddd.trace.enabled=false"] as String[]
, "" as String[]
, [:]
, true) == 0
@ -52,7 +52,7 @@ class LogLevelTest extends Specification {
def "DD_TRACE_DEBUG is true"() {
expect:
IntegrationTestUtils.runOnSeparateJvm(LogLevelChecker.getName()
, ["-Ddd.jmxfetch.enabled=false","-Ddd.trace.enabled=false"] as String[]
, ["-Ddd.trace.enabled=false"] as String[]
, "" as String[]
, ["DD_TRACE_DEBUG": "true"]
, true) == 0
@ -61,7 +61,7 @@ class LogLevelTest extends Specification {
def "dd.trace.debug is true && DD_TRACE_DEBUG is false"() {
expect:
IntegrationTestUtils.runOnSeparateJvm(LogLevelChecker.getName()
, ["-Ddd.trace.debug=true","-Ddd.jmxfetch.enabled=false","-Ddd.trace.enabled=false"] as String[]
, ["-Ddd.trace.debug=true","-Ddd.trace.enabled=false"] as String[]
, "" as String[]
, ["DD_TRACE_DEBUG": "false"]
, true) == 0
@ -72,7 +72,7 @@ class LogLevelTest extends Specification {
def "SLF4J DEBUG && DD_TRACE_DEBUG is false"() {
expect:
IntegrationTestUtils.runOnSeparateJvm(LogLevelChecker.getName()
, ["-Ddatadog.slf4j.simpleLogger.defaultLogLevel=debug","-Ddd.jmxfetch.enabled=false","-Ddd.trace.enabled=false"] as String[]
, ["-Ddatadog.slf4j.simpleLogger.defaultLogLevel=debug","-Ddd.trace.enabled=false"] as String[]
, "" as String[]
, ["DD_TRACE_DEBUG": "false"]
, true) == 0
@ -81,7 +81,7 @@ class LogLevelTest extends Specification {
def "SLF4J INFO && DD_TRACE_DEBUG is true"() {
expect:
IntegrationTestUtils.runOnSeparateJvm(LogLevelChecker.getName()
, ["-Ddatadog.slf4j.simpleLogger.defaultLogLevel=info","-Ddd.jmxfetch.enabled=false","-Ddd.trace.enabled=false"] as String[]
, ["-Ddatadog.slf4j.simpleLogger.defaultLogLevel=info","-Ddd.trace.enabled=false"] as String[]
, "" as String[]
, ["DD_TRACE_DEBUG": "true"]
, true) == 1

View File

@ -58,7 +58,6 @@ class ShadowPackageRenamingTest extends Specification {
def "agent jar contains no bootstrap classes"() {
setup:
final ClassPath agentClasspath = ClassPath.from(IntegrationTestUtils.getAgentClassLoader())
final ClassPath jmxFetchClasspath = ClassPath.from(IntegrationTestUtils.getJmxFetchClassLoader())
final ClassPath bootstrapClasspath = ClassPath.from(IntegrationTestUtils.getBootstrapProxy())
final Set<String> bootstrapClasses = new HashSet<>()
@ -99,28 +98,9 @@ class ShadowPackageRenamingTest extends Specification {
}
}
final List<ClassPath.ClassInfo> jmxFetchDuplicateClassFile = new ArrayList<>()
final List<String> badJmxFetchPrefixes = []
for (ClassPath.ClassInfo classInfo : jmxFetchClasspath.getAllClasses()) {
if (bootstrapClasses.contains(classInfo.getName())) {
jmxFetchDuplicateClassFile.add(classInfo)
}
boolean goodPrefix = true
for (int i = 0; i < bootstrapPrefixes.length; ++i) {
if (classInfo.getName().startsWith(bootstrapPrefixes[i])) {
goodPrefix = false
break
}
}
if (!goodPrefix) {
badJmxFetchPrefixes.add(classInfo.getName())
}
}
expect:
agentDuplicateClassFile == []
badBootstrapPrefixes == []
badAgentPrefixes == []
badJmxFetchPrefixes == []
}
}

View File

@ -33,11 +33,6 @@ public class IntegrationTestUtils {
return getTracingAgentFieldClassloader("AGENT_CLASSLOADER");
}
/** Returns the classloader the jmxfetch is running on. */
public static ClassLoader getJmxFetchClassLoader() {
return getTracingAgentFieldClassloader("JMXFETCH_CLASSLOADER");
}
private static ClassLoader getTracingAgentFieldClassloader(final String fieldName) {
Field classloaderField = null;
try {

View File

@ -1,5 +0,0 @@
package jvmbootstraptest;
import java.util.logging.LogManager;
public class CustomLogManager extends LogManager {}

View File

@ -1,84 +0,0 @@
package jvmbootstraptest;
import java.util.logging.LogManager;
public class LogManagerSetter {
public static void main(final String... args) throws Exception {
if (System.getProperty("dd.app.customlogmanager") != null) {
if (Boolean.valueOf(System.getProperty("dd.app.customlogmanager"))) {
System.setProperty("java.util.logging.manager", CustomLogManager.class.getName());
customAssert(
LogManager.getLogManager().getClass(),
LogManagerSetter.class
.getClassLoader()
.loadClass(System.getProperty("java.util.logging.manager")),
"Javaagent should not prevent setting a custom log manager");
} else {
customAssert(
isJmxfetchStarted(),
true,
"jmxfetch should start in premain when customlogmanager=false.");
}
} else if (System.getProperty("java.util.logging.manager") != null) {
if (ClassLoader.getSystemResource(
System.getProperty("java.util.logging.manager").replaceAll("\\.", "/") + ".class")
== null) {
customAssert(
isJmxfetchStarted(),
false,
"jmxfetch startup must be delayed when log manager system property is present.");
// Change back to a valid LogManager.
System.setProperty("java.util.logging.manager", CustomLogManager.class.getName());
customAssert(
LogManager.getLogManager().getClass(),
LogManagerSetter.class
.getClassLoader()
.loadClass(System.getProperty("java.util.logging.manager")),
"Javaagent should not prevent setting a custom log manager");
customAssert(isJmxfetchStarted(), true, "jmxfetch should start after loading LogManager.");
} else {
customAssert(
isJmxfetchStarted(),
true,
"jmxfetch should start in premain when custom log manager found on classpath.");
}
} else if (System.getenv("JBOSS_HOME") != null) {
customAssert(
isJmxfetchStarted(),
false,
"jmxfetch startup must be delayed when JBOSS_HOME property is present.");
System.setProperty("java.util.logging.manager", CustomLogManager.class.getName());
customAssert(
LogManager.getLogManager().getClass(),
LogManagerSetter.class
.getClassLoader()
.loadClass(System.getProperty("java.util.logging.manager")),
"Javaagent should not prevent setting a custom log manager");
customAssert(
isJmxfetchStarted(), true, "jmxfetch should start after loading with JBOSS_HOME SET.");
} else {
customAssert(
isJmxfetchStarted(),
true,
"jmxfetch should start in premain when no custom log manager is set.");
}
}
private static void customAssert(
final Object got, final Object expected, final String assertionMessage) {
if ((null == got && got != expected) || !got.equals(expected)) {
throw new RuntimeException(
"Assertion failed. Expected <" + expected + "> got <" + got + "> " + assertionMessage);
}
}
private static boolean isJmxfetchStarted() {
for (final Thread thread : Thread.getAllStackTraces().keySet()) {
if ("dd-jmx-collector".equals(thread.getName())) {
return true;
}
}
return false;
}
}

View File

@ -78,15 +78,6 @@ 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 JMX_FETCH_ENABLED = "jmxfetch.enabled";
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";
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";
@ -127,9 +118,6 @@ public class Config {
private static final int DEFAULT_PARTIAL_FLUSH_MIN_SPANS = 1000;
private static final String DEFAULT_PROPAGATION_STYLE_EXTRACT = PropagationStyle.DATADOG.name();
private static final String DEFAULT_PROPAGATION_STYLE_INJECT = PropagationStyle.DATADOG.name();
private static final boolean DEFAULT_JMX_FETCH_ENABLED = true;
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
@ -188,16 +176,6 @@ public class Config {
@Getter private final Set<PropagationStyle> propagationStylesToExtract;
@Getter private final Set<PropagationStyle> propagationStylesToInject;
@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;
@Getter private final Integer jmxFetchRefreshBeansPeriod;
@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;
@ -300,18 +278,6 @@ public class Config {
PropagationStyle.class,
true);
jmxFetchEnabled =
getBooleanSettingFromEnvironment(JMX_FETCH_ENABLED, DEFAULT_JMX_FETCH_ENABLED);
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 =
getIntegerSettingFromEnvironment(JMX_FETCH_REFRESH_BEANS_PERIOD, null);
jmxFetchStatsdHost = getSettingFromEnvironment(JMX_FETCH_STATSD_HOST, null);
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);
@ -420,21 +386,6 @@ public class Config {
? parent.propagationStylesToInject
: parsedPropagationStylesToInject;
jmxFetchEnabled =
getPropertyBooleanValue(properties, JMX_FETCH_ENABLED, parent.jmxFetchEnabled);
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 =
getPropertyIntegerValue(properties, JMX_FETCH_CHECK_PERIOD, parent.jmxFetchCheckPeriod);
jmxFetchRefreshBeansPeriod =
getPropertyIntegerValue(
properties, JMX_FETCH_REFRESH_BEANS_PERIOD, parent.jmxFetchRefreshBeansPeriod);
jmxFetchStatsdHost = properties.getProperty(JMX_FETCH_STATSD_HOST, parent.jmxFetchStatsdHost);
jmxFetchStatsdPort =
getPropertyIntegerValue(properties, JMX_FETCH_STATSD_PORT, parent.jmxFetchStatsdPort);
healthMetricsEnabled =
getPropertyBooleanValue(properties, HEALTH_METRICS_ENABLED, DEFAULT_METRICS_ENABLED);
healthMetricsStatsdHost =
@ -560,35 +511,6 @@ public class Config {
return anyEnabled;
}
public boolean isJmxFetchIntegrationEnabled(
final SortedSet<String> integrationNames, final boolean defaultEnabled) {
return jmxFetchIntegrationEnabled(integrationNames, defaultEnabled);
}
/**
* @deprecated This method should only be used internally. Use the instance getter instead {@link
* #isJmxFetchIntegrationEnabled(SortedSet, boolean)}.
* @param integrationNames
* @param defaultEnabled
* @return
*/
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 boolean isTraceAnalyticsIntegrationEnabled(
final SortedSet<String> integrationNames, final boolean defaultEnabled) {
return traceAnalyticsIntegrationEnabled(integrationNames, defaultEnabled);

View File

@ -10,18 +10,14 @@ import static datadog.trace.api.Config.AGENT_PORT_LEGACY
import static datadog.trace.api.Config.AGENT_UNIX_DOMAIN_SOCKET
import static datadog.trace.api.Config.CONFIGURATION_FILE
import static datadog.trace.api.Config.DB_CLIENT_HOST_SPLIT_BY_INSTANCE
import static datadog.trace.api.Config.DEFAULT_JMX_FETCH_STATSD_PORT
import static datadog.trace.api.Config.GLOBAL_TAGS
import static datadog.trace.api.Config.HEADER_TAGS
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
import static datadog.trace.api.Config.HTTP_CLIENT_ERROR_STATUSES
import static datadog.trace.api.Config.HTTP_CLIENT_HOST_SPLIT_BY_DOMAIN
import static datadog.trace.api.Config.HTTP_SERVER_ERROR_STATUSES
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_STATSD_HOST
import static datadog.trace.api.Config.JMX_FETCH_STATSD_PORT
import static datadog.trace.api.Config.JMX_TAGS
import static datadog.trace.api.Config.PARTIAL_FLUSH_MIN_SPANS
import static datadog.trace.api.Config.PREFIX
@ -40,9 +36,6 @@ 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
@ -58,7 +51,6 @@ class ConfigTest extends DDSpecification {
private static final DD_HEADER_TAGS_ENV = "DD_HEADER_TAGS"
private static final DD_PROPAGATION_STYLE_EXTRACT = "DD_PROPAGATION_STYLE_EXTRACT"
private static final DD_PROPAGATION_STYLE_INJECT = "DD_PROPAGATION_STYLE_INJECT"
private static final DD_JMXFETCH_METRICS_CONFIGS_ENV = "DD_JMXFETCH_METRICS_CONFIGS"
private static final DD_TRACE_AGENT_PORT_ENV = "DD_TRACE_AGENT_PORT"
private static final DD_AGENT_PORT_LEGACY_ENV = "DD_AGENT_PORT"
private static final DD_TRACE_REPORT_HOSTNAME = "DD_TRACE_REPORT_HOSTNAME"
@ -90,12 +82,6 @@ class ConfigTest extends DDSpecification {
config.runtimeContextFieldInjection == true
config.propagationStylesToExtract.toList() == [Config.PropagationStyle.DATADOG]
config.propagationStylesToInject.toList() == [Config.PropagationStyle.DATADOG]
config.jmxFetchEnabled == true
config.jmxFetchMetricsConfigs == []
config.jmxFetchCheckPeriod == null
config.jmxFetchRefreshBeansPeriod == null
config.jmxFetchStatsdHost == null
config.jmxFetchStatsdPort == DEFAULT_JMX_FETCH_STATSD_PORT
config.healthMetricsEnabled == false
config.healthMetricsStatsdHost == null
config.healthMetricsStatsdPort == null
@ -136,12 +122,6 @@ class ConfigTest extends DDSpecification {
prop.setProperty(RUNTIME_CONTEXT_FIELD_INJECTION, "false")
prop.setProperty(PROPAGATION_STYLE_EXTRACT, "Datadog, B3")
prop.setProperty(PROPAGATION_STYLE_INJECT, "B3, Datadog")
prop.setProperty(JMX_FETCH_ENABLED, "false")
prop.setProperty(JMX_FETCH_METRICS_CONFIGS, "/foo.yaml,/bar.yaml")
prop.setProperty(JMX_FETCH_CHECK_PERIOD, "100")
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")
@ -172,12 +152,6 @@ class ConfigTest extends DDSpecification {
config.runtimeContextFieldInjection == false
config.propagationStylesToExtract.toList() == [Config.PropagationStyle.DATADOG, Config.PropagationStyle.B3]
config.propagationStylesToInject.toList() == [Config.PropagationStyle.B3, Config.PropagationStyle.DATADOG]
config.jmxFetchEnabled == false
config.jmxFetchMetricsConfigs == ["/foo.yaml", "/bar.yaml"]
config.jmxFetchCheckPeriod == 100
config.jmxFetchRefreshBeansPeriod == 200
config.jmxFetchStatsdHost == "statsd host"
config.jmxFetchStatsdPort == 321
config.healthMetricsEnabled == true
config.healthMetricsStatsdHost == "metrics statsd host"
config.healthMetricsStatsdPort == 654
@ -209,12 +183,6 @@ class ConfigTest extends DDSpecification {
System.setProperty(PREFIX + RUNTIME_CONTEXT_FIELD_INJECTION, "false")
System.setProperty(PREFIX + PROPAGATION_STYLE_EXTRACT, "Datadog, B3")
System.setProperty(PREFIX + PROPAGATION_STYLE_INJECT, "B3, Datadog")
System.setProperty(PREFIX + JMX_FETCH_ENABLED, "false")
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")
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")
@ -245,12 +213,6 @@ class ConfigTest extends DDSpecification {
config.runtimeContextFieldInjection == false
config.propagationStylesToExtract.toList() == [Config.PropagationStyle.DATADOG, Config.PropagationStyle.B3]
config.propagationStylesToInject.toList() == [Config.PropagationStyle.B3, Config.PropagationStyle.DATADOG]
config.jmxFetchEnabled == false
config.jmxFetchMetricsConfigs == ["/foo.yaml", "/bar.yaml"]
config.jmxFetchCheckPeriod == 100
config.jmxFetchRefreshBeansPeriod == 200
config.jmxFetchStatsdHost == "statsd host"
config.jmxFetchStatsdPort == 321
config.healthMetricsEnabled == true
config.healthMetricsStatsdHost == "metrics statsd host"
config.healthMetricsStatsdPort == 654
@ -263,7 +225,6 @@ class ConfigTest extends DDSpecification {
environmentVariables.set(DD_WRITER_TYPE_ENV, "LoggingWriter")
environmentVariables.set(DD_PROPAGATION_STYLE_EXTRACT, "B3 Datadog")
environmentVariables.set(DD_PROPAGATION_STYLE_INJECT, "Datadog B3")
environmentVariables.set(DD_JMXFETCH_METRICS_CONFIGS_ENV, "some/file")
environmentVariables.set(DD_TRACE_REPORT_HOSTNAME, "true")
when:
@ -275,7 +236,6 @@ class ConfigTest extends DDSpecification {
config.writerType == "LoggingWriter"
config.propagationStylesToExtract.toList() == [Config.PropagationStyle.B3, Config.PropagationStyle.DATADOG]
config.propagationStylesToInject.toList() == [Config.PropagationStyle.DATADOG, Config.PropagationStyle.B3]
config.jmxFetchMetricsConfigs == ["some/file"]
config.reportHostName == true
}
@ -408,11 +368,6 @@ class ConfigTest extends DDSpecification {
properties.setProperty(PARTIAL_FLUSH_MIN_SPANS, "15")
properties.setProperty(PROPAGATION_STYLE_EXTRACT, "B3 Datadog")
properties.setProperty(PROPAGATION_STYLE_INJECT, "Datadog B3")
properties.setProperty(JMX_FETCH_METRICS_CONFIGS, "/foo.yaml,/bar.yaml")
properties.setProperty(JMX_FETCH_CHECK_PERIOD, "100")
properties.setProperty(JMX_FETCH_REFRESH_BEANS_PERIOD, "200")
properties.setProperty(JMX_FETCH_STATSD_HOST, "statsd host")
properties.setProperty(JMX_FETCH_STATSD_PORT, "321")
when:
def config = Config.get(properties)
@ -438,11 +393,6 @@ class ConfigTest extends DDSpecification {
config.partialFlushMinSpans == 15
config.propagationStylesToExtract.toList() == [Config.PropagationStyle.B3, Config.PropagationStyle.DATADOG]
config.propagationStylesToInject.toList() == [Config.PropagationStyle.DATADOG, Config.PropagationStyle.B3]
config.jmxFetchMetricsConfigs == ["/foo.yaml", "/bar.yaml"]
config.jmxFetchCheckPeriod == 100
config.jmxFetchRefreshBeansPeriod == 200
config.jmxFetchStatsdHost == "statsd host"
config.jmxFetchStatsdPort == 321
}
def "override null properties"() {
@ -513,40 +463,6 @@ class ConfigTest extends DDSpecification {
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.get().isJmxFetchIntegrationEnabled(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")
@ -713,21 +629,6 @@ class ConfigTest extends DDSpecification {
"" | [:]
}
def "verify empty value list configs on tracer"() {
setup:
System.setProperty(PREFIX + JMX_FETCH_METRICS_CONFIGS, listString)
when:
def config = new Config()
then:
config.jmxFetchMetricsConfigs == list
where:
listString | list
"" | []
}
def "verify hostname not added to root span tags by default"() {
setup:
Properties properties = new Properties()

View File

@ -75,16 +75,13 @@ public interface Writer extends Closeable {
return new DDAgentWriter.NoopMonitor();
} else {
String host = config.getHealthMetricsStatsdHost();
if (host == null) {
host = config.getJmxFetchStatsdHost();
}
if (host == null) {
host = config.getAgentHost();
}
Integer port = config.getHealthMetricsStatsdPort();
if (port == null) {
port = config.getJmxFetchStatsdPort();
return new DDAgentWriter.NoopMonitor();
}
return new DDAgentWriter.StatsDMonitor(host, port);

View File

@ -16,6 +16,7 @@ import org.junit.contrib.java.lang.system.RestoreSystemProperties
import static datadog.trace.api.Config.DEFAULT_SERVICE_NAME
import static datadog.trace.api.Config.HEADER_TAGS
import static datadog.trace.api.Config.HEALTH_METRICS_ENABLED
import static datadog.trace.api.Config.HEALTH_METRICS_STATSD_PORT
import static datadog.trace.api.Config.PREFIX
import static datadog.trace.api.Config.PRIORITY_SAMPLING
import static datadog.trace.api.Config.SERVICE_MAPPING
@ -58,6 +59,7 @@ class DDTracerTest extends DDSpecification {
def "verify enabling health monitor"() {
setup:
System.setProperty(PREFIX + HEALTH_METRICS_ENABLED, "true")
System.setProperty(PREFIX + HEALTH_METRICS_STATSD_PORT, "8125")
when:
def tracer = new DDTracer(new Config())

View File

@ -8,7 +8,6 @@ ext {
slf4j : "1.7.28",
guava : "20.0", // Last version to support Java 7
// When upgrading for security fixes, ensure corresponding change is reflected in jmxfetch.
jackson : "2.10.0", // https://nvd.nist.gov/vuln/detail/CVE-2019-16942 et al
spock : "1.3-groovy-$spockGroovyVer",

View File

@ -8,7 +8,6 @@ include ':dd-trace-ot'
include ':dd-java-agent'
include ':dd-java-agent:agent-bootstrap'
include ':dd-java-agent:agent-tooling'
include ':dd-java-agent:agent-jmxfetch'
// misc
include ':dd-java-agent:testing'