Move integrations config to Config class.
MODIFY
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/Instrumenter.java
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/Instrumenter.java
@@ -227,15 +227,5 @@ public interface Instrumenter {
protected boolean defaultEnabled() {
return getConfigEnabled("dd.integrations.enabled", true);
}
-
- // TODO: move common config helpers to Utils
-
- public static String getPropOrEnv(final String name) {
- return System.getProperty(name, System.getenv(propToEnvName(name)));
- }
-
- public static String propToEnvName(final String name) {
- return name.toUpperCase().replace(".", "_");
- }
}
}

MODIFY
dd-java-agent/instrumentation/slf4j-mdc/src/main/java/datadog/trace/instrumentation/slf4j/mdc/MDCInjectionInstrumentation.java
dd-java-agent/instrumentation/slf4j-mdc/src/main/java/datadog/trace/instrumentation/slf4j/mdc/MDCInjectionInstrumentation.java
@@ -34,10 +34,8 @@ public class MDCInjectionInstrumentation extends Instrumenter.Default {
@Override
protected boolean defaultEnabled() {
- final String enableInjection = getPropOrEnv("dd." + Config.LOGS_INJECTION_ENABLED);
- return null == enableInjection
- ? Config.DEFAULT_LOGS_INJECTION_ENABLED
- : Boolean.parseBoolean(enableInjection);
+ return Config.getBooleanSettingFromEnvironment(
+ Config.LOGS_INJECTION_ENABLED, Config.DEFAULT_LOGS_INJECTION_ENABLED);
}
@Override

MODIFY
dd-java-agent/instrumentation/trace-annotation/src/main/java/datadog/trace/instrumentation/trace_annotation/TraceAnnotationsInstrumentation.java
dd-java-agent/instrumentation/trace-annotation/src/main/java/datadog/trace/instrumentation/trace_annotation/TraceAnnotationsInstrumentation.java
@@ -10,6 +10,7 @@ import static net.bytebuddy.matcher.ElementMatchers.named;
import com.google.auto.service.AutoService;
import com.google.common.collect.Sets;
import datadog.trace.agent.tooling.Instrumenter;
+import datadog.trace.api.Config;
import datadog.trace.api.Trace;
import java.util.Collections;
import java.util.Map;
@@ -23,7 +24,6 @@ import net.bytebuddy.matcher.ElementMatcher;
@Slf4j
@AutoService(Instrumenter.class)
public final class TraceAnnotationsInstrumentation extends Instrumenter.Default {
- private static final String CONFIG_NAME = "dd.trace.annotations";
static final String CONFIG_FORMAT =
"(?:\\s*"
@@ -47,7 +47,7 @@ public final class TraceAnnotationsInstrumentation extends Instrumenter.Default
public TraceAnnotationsInstrumentation() {
super("trace", "trace-annotation");
- final String configString = getPropOrEnv(CONFIG_NAME);
+ final String configString = Config.getSettingFromEnvironment(Config.TRACE_ANNOTATIONS, null);
if (configString == null) {
additionalTraceAnnotations =
Collections.unmodifiableSet(Sets.<String>newHashSet(DEFAULT_ANNOTATIONS));

MODIFY
dd-java-agent/instrumentation/trace-annotation/src/main/java/datadog/trace/instrumentation/trace_annotation/TraceConfigInstrumentation.java
dd-java-agent/instrumentation/trace-annotation/src/main/java/datadog/trace/instrumentation/trace_annotation/TraceConfigInstrumentation.java
@@ -7,6 +7,7 @@ import com.google.auto.service.AutoService;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import datadog.trace.agent.tooling.Instrumenter;
+import datadog.trace.api.Config;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -29,7 +30,6 @@ import net.bytebuddy.matcher.ElementMatcher;
@Slf4j
@AutoService(Instrumenter.class)
public class TraceConfigInstrumentation implements Instrumenter {
- private static final String CONFIG_NAME = "dd.trace.methods";
static final String PACKAGE_CLASS_NAME_REGEX = "[\\w.\\$]+";
private static final String METHOD_LIST_REGEX = "\\s*(?:\\w+\\s*,)*\\s*(?:\\w+\\s*,?)\\s*";
@@ -47,7 +47,7 @@ public class TraceConfigInstrumentation implements Instrumenter {
private final Map<String, Set<String>> classMethodsToTrace;
public TraceConfigInstrumentation() {
- final String configString = Default.getPropOrEnv(CONFIG_NAME);
+ final String configString = Config.getSettingFromEnvironment(Config.TRACE_METHODS, null);
if (configString == null || configString.trim().isEmpty()) {
classMethodsToTrace = Collections.emptyMap();

MODIFY
dd-trace-api/src/main/java/datadog/trace/api/Config.java
dd-trace-api/src/main/java/datadog/trace/api/Config.java
@@ -40,6 +40,8 @@ public class Config {
public static final String GLOBAL_TAGS = "trace.global.tags";
public static final String SPAN_TAGS = "trace.span.tags";
public static final String JMX_TAGS = "trace.jmx.tags";
+ public static final String TRACE_ANNOTATIONS = "trace.annotations";
+ public static final String TRACE_METHODS = "trace.methods";
public static final String HEADER_TAGS = "trace.header.tags";
public static final String HTTP_CLIENT_HOST_SPLIT_BY_DOMAIN = "trace.http.client.split-by-domain";
public static final String PARTIAL_FLUSH_MIN_SPANS = "trace.partial.flush.min.spans";

Move integrations config to Config class.