Move bootstrap prefixes to classloader matcher
MODIFY
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/ClassLoaderMatcher.java
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/ClassLoaderMatcher.java
@@ -9,6 +9,11 @@ import net.bytebuddy.matcher.ElementMatcher;
@Slf4j
public class ClassLoaderMatcher {
+ /* packages which will be loaded on the bootstrap classloader*/
+ public static final String[] BOOTSTRAP_PACKAGE_PREFIXES = {
+ "io.opentracing", "datadog.slf4j", "datadog.trace"
+ };
+
/** A private constructor that must not be invoked. */
private ClassLoaderMatcher() {
throw new UnsupportedOperationException();

MODIFY
dd-java-agent/instrumentation/jboss-classloading/src/main/java/datadog/trace/instrumentation/jboss/JBossClassloadingInstrumentation.java
dd-java-agent/instrumentation/jboss-classloading/src/main/java/datadog/trace/instrumentation/jboss/JBossClassloadingInstrumentation.java
@@ -3,6 +3,7 @@ package datadog.trace.instrumentation.jboss;
import static net.bytebuddy.matcher.ElementMatchers.named;
import com.google.auto.service.AutoService;
+import datadog.trace.agent.tooling.ClassLoaderMatcher;
import datadog.trace.agent.tooling.Instrumenter;
import net.bytebuddy.agent.builder.AgentBuilder;
import net.bytebuddy.description.type.TypeDescription;
@@ -11,10 +12,6 @@ import net.bytebuddy.utility.JavaModule;
@AutoService(Instrumenter.class)
public final class JBossClassloadingInstrumentation extends Instrumenter.Configurable {
- private static final String[] BOOTSTRAP_PACKAGE_PREFIXES = {
- "io.opentracing", "datadog.slf4j", "datadog.trace"
- };
-
public JBossClassloadingInstrumentation() {
super("jboss-classloading");
}
@@ -36,11 +33,11 @@ public final class JBossClassloadingInstrumentation extends Instrumenter.Configu
// Instead it sets a system prop to tell jboss to delegate
// classloads for datadog bootstrap classes
StringBuilder ddPrefixes = new StringBuilder("");
- for (int i = 0; i < BOOTSTRAP_PACKAGE_PREFIXES.length; ++i) {
+ for (int i = 0; i < ClassLoaderMatcher.BOOTSTRAP_PACKAGE_PREFIXES.length; ++i) {
if (i > 0) {
ddPrefixes.append(",");
}
- ddPrefixes.append(BOOTSTRAP_PACKAGE_PREFIXES[i]);
+ ddPrefixes.append(ClassLoaderMatcher.BOOTSTRAP_PACKAGE_PREFIXES[i]);
}
final String existing = System.getProperty("jboss.modules.system.pkgs");
if (null == existing) {

MODIFY
dd-java-agent/instrumentation/osgi-classloading/src/main/java/datadog/trace/instrumentation/osgi/OSGIClassloadingInstrumentation.java
dd-java-agent/instrumentation/osgi-classloading/src/main/java/datadog/trace/instrumentation/osgi/OSGIClassloadingInstrumentation.java
@@ -3,6 +3,7 @@ package datadog.trace.instrumentation.osgi;
import static net.bytebuddy.matcher.ElementMatchers.named;
import com.google.auto.service.AutoService;
+import datadog.trace.agent.tooling.ClassLoaderMatcher;
import datadog.trace.agent.tooling.Instrumenter;
import net.bytebuddy.agent.builder.AgentBuilder;
import net.bytebuddy.description.type.TypeDescription;
@@ -11,10 +12,6 @@ import net.bytebuddy.utility.JavaModule;
@AutoService(Instrumenter.class)
public final class OSGIClassloadingInstrumentation extends Instrumenter.Configurable {
- private static final String[] BOOTSTRAP_PACKAGE_PREFIXES = {
- "io.opentracing", "datadog.slf4j", "datadog.trace"
- };
-
public OSGIClassloadingInstrumentation() {
super("osgi-classloading");
}
@@ -36,13 +33,13 @@ public final class OSGIClassloadingInstrumentation extends Instrumenter.Configur
// Instead it sets a system prop to tell osgi to delegate
// classloads for datadog bootstrap classes
StringBuilder ddPrefixes = new StringBuilder("");
- for (int i = 0; i < BOOTSTRAP_PACKAGE_PREFIXES.length; ++i) {
+ for (int i = 0; i < ClassLoaderMatcher.BOOTSTRAP_PACKAGE_PREFIXES.length; ++i) {
if (i > 0) {
// must append twice. Once for exact package and wildcard for child packages
ddPrefixes.append(",");
}
- ddPrefixes.append(BOOTSTRAP_PACKAGE_PREFIXES[i]).append(".*,");
- ddPrefixes.append(BOOTSTRAP_PACKAGE_PREFIXES[i]);
+ ddPrefixes.append(ClassLoaderMatcher.BOOTSTRAP_PACKAGE_PREFIXES[i]).append(".*,");
+ ddPrefixes.append(ClassLoaderMatcher.BOOTSTRAP_PACKAGE_PREFIXES[i]);
}
final String existing = System.getProperty("org.osgi.framework.bootdelegation");
if (null == existing) {

Move bootstrap prefixes to classloader matcher