Rework test logic for ignores. Add spring proxy to global ignore list
MODIFY
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/AgentInstaller.java
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/AgentInstaller.java
package datadog.trace.agent.tooling;
import static datadog.trace.agent.tooling.ClassLoaderMatcher.skipClassLoader;
-import static datadog.trace.agent.tooling.bytebuddy.matcher.AdditionalLibraryIgnoresMatcher.additionalLibraryIgnoresMatcher;
import static datadog.trace.agent.tooling.bytebuddy.matcher.GlobalIgnoresMatcher.globalIgnoresMatcher;
import static net.bytebuddy.matcher.ElementMatchers.any;
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.none;
-import static net.bytebuddy.matcher.ElementMatchers.not;
import datadog.trace.agent.tooling.context.FieldBackedProvider;
import datadog.trace.api.Config;
@@ -72,18 +70,10 @@ public class AgentInstaller {
// https://github.com/raphw/byte-buddy/issues/558
// .with(AgentBuilder.LambdaInstrumentationStrategy.ENABLED)
.ignore(any(), skipClassLoader());
- if (skipAdditionalLibraryMatcher) {
- // Ignore classes matched by globalIgnoresMatcher but not matched by
- // additionalLibraryIgnoresMatcher.
- // Note: globalIgnoresMatcher includes additionalLibraryIgnoresMatcher internally for
- // efficiency purposes.
- // Note2: this is expected to be used by tests only.
+
ignoredAgentBuilder =
- ignoredAgentBuilder.or(
- globalIgnoresMatcher().and(not(additionalLibraryIgnoresMatcher())));
- } else {
- ignoredAgentBuilder = ignoredAgentBuilder.or(globalIgnoresMatcher());
- }
+ ignoredAgentBuilder.or(globalIgnoresMatcher(skipAdditionalLibraryMatcher));
+
ignoredAgentBuilder = ignoredAgentBuilder.or(matchesConfiguredExcludes());
AgentBuilder agentBuilder = ignoredAgentBuilder;

MODIFY
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/bytebuddy/matcher/GlobalIgnoresMatcher.java
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/bytebuddy/matcher/GlobalIgnoresMatcher.java
@@ -26,12 +26,18 @@ public class GlobalIgnoresMatcher<T extends TypeDescription>
private static final Pattern COM_MCHANGE_PROXY =
Pattern.compile("com\\.mchange\\.v2\\.c3p0\\..*Proxy");
- public static <T extends TypeDescription> ElementMatcher.Junction<T> globalIgnoresMatcher() {
- return new GlobalIgnoresMatcher<>();
+ public static <T extends TypeDescription> ElementMatcher.Junction<T> globalIgnoresMatcher(
+ final boolean skipAdditionalLibraryMatcher) {
+ return new GlobalIgnoresMatcher<>(skipAdditionalLibraryMatcher);
}
private final ElementMatcher<T> additionalLibraryIgnoreMatcher =
AdditionalLibraryIgnoresMatcher.additionalLibraryIgnoresMatcher();
+ private final boolean skipAdditionalLibraryMatcher;
+
+ private GlobalIgnoresMatcher(final boolean skipAdditionalLibraryMatcher) {
+ this.skipAdditionalLibraryMatcher = skipAdditionalLibraryMatcher;
+ }
/**
* Be very careful about the types of matchers used in this section as they are called on every
@@ -140,7 +146,8 @@ public class GlobalIgnoresMatcher<T extends TypeDescription>
|| name.contains("CGLIB$$")
|| name.contains("javassist")
|| name.contains(".asm.")
- || name.contains("$__sisu")) {
+ || name.contains("$__sisu")
+ || name.startsWith("org.springframework.core.$Proxy")) {
return true;
}
@@ -148,9 +155,11 @@ public class GlobalIgnoresMatcher<T extends TypeDescription>
return true;
}
+ if (!skipAdditionalLibraryMatcher) {
if (additionalLibraryIgnoreMatcher.matches(target)) {
return true;
}
+ }
return false;
}

Rework test logic for ignores. Add spring proxy to global ignore list