Add special handling for ignoring `javax.decorator.Decorator` annotated classes.
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
@@ -2,7 +2,6 @@ package datadog.trace.agent.tooling;
import static datadog.trace.agent.tooling.ClassLoaderMatcher.skipClassLoader;
import static net.bytebuddy.matcher.ElementMatchers.any;
-import static net.bytebuddy.matcher.ElementMatchers.isAnnotatedWith;
import static net.bytebuddy.matcher.ElementMatchers.nameContains;
import static net.bytebuddy.matcher.ElementMatchers.nameMatches;
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
@@ -24,7 +23,6 @@ import net.bytebuddy.agent.builder.ResettableClassFileTransformer;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.dynamic.DynamicType;
import net.bytebuddy.matcher.ElementMatcher;
-import net.bytebuddy.matcher.ElementMatchers;
import net.bytebuddy.utility.JavaModule;
@Slf4j

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
@@ -2,6 +2,9 @@ package datadog.trace.agent.tooling;
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.failSafe;
import static net.bytebuddy.matcher.ElementMatchers.any;
+import static net.bytebuddy.matcher.ElementMatchers.isAnnotatedWith;
+import static net.bytebuddy.matcher.ElementMatchers.named;
+import static net.bytebuddy.matcher.ElementMatchers.not;
import datadog.trace.agent.tooling.context.FieldBackedProvider;
import datadog.trace.agent.tooling.context.InstrumentationContextProvider;
@@ -73,6 +76,9 @@ public interface Instrumenter {
classLoaderMatcher(),
"Instrumentation class loader matcher unexpected exception: "
+ getClass().getName()))
+ // Added here instead of AgentInstaller's ignores because it's relatively
+ // expensive. https://github.com/DataDog/dd-trace-java/pull/1045
+ .and(not(isAnnotatedWith(named("javax.decorator.Decorator"))))
.and(new MuzzleMatcher())
.and(new PostMatchHook())
.transform(DDTransformers.defaultTransformers());

MODIFY
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/context/FieldBackedProvider.java
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/context/FieldBackedProvider.java
@@ -2,6 +2,7 @@ package datadog.trace.agent.tooling.context;
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
import static datadog.trace.agent.tooling.ClassLoaderMatcher.BOOTSTRAP_CLASSLOADER;
+import static net.bytebuddy.matcher.ElementMatchers.isAnnotatedWith;
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.not;
@@ -354,9 +355,12 @@ public class FieldBackedProvider implements InstrumentationContextProvider {
builder =
builder
.type(
- safeHasSuperType(named(entry.getKey())).and(not(isInterface())),
+ not(isInterface()).and(safeHasSuperType(named(entry.getKey()))),
instrumenter.classLoaderMatcher())
.and(safeToInjectFieldsMatcher())
+ // Added here instead of AgentInstaller's ignores because it's relatively
+ // expensive. https://github.com/DataDog/dd-trace-java/pull/1045
+ .and(not(isAnnotatedWith(named("javax.decorator.Decorator"))))
.transform(AgentBuilder.Transformer.NoOp.INSTANCE);
/**

MODIFY
dd-java-agent/instrumentation/cdi-1.2/src/test/groovy/CDIContainerTest.groovy
dd-java-agent/instrumentation/cdi-1.2/src/test/groovy/CDIContainerTest.groovy
import datadog.trace.agent.test.AgentTestRunner
-import datadog.trace.instrumentation.TestBean
import org.jboss.weld.environment.se.Weld
import org.jboss.weld.environment.se.WeldContainer
import org.jboss.weld.environment.se.threading.RunnableDecorator

RENAME
dd-java-agent/instrumentation/cdi-1.2/src/test/java/datadog/trace/instrumentation/TestBean.java
dd-java-agent/instrumentation/cdi-1.2/src/test/java/TestBean.java
-package datadog.trace.instrumentation;
-
public class TestBean {
private String someField;

Add special handling for ignoring `javax.decorator.Decorator` annotated classes.