Dont instrument `@Decorator`s or CDI breaks
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 net.bytebuddy.matcher.ElementMatchers.annotationType;
import static net.bytebuddy.matcher.ElementMatchers.any;
+import static net.bytebuddy.matcher.ElementMatchers.hasAnnotation;
import static net.bytebuddy.matcher.ElementMatchers.nameContains;
import static net.bytebuddy.matcher.ElementMatchers.nameMatches;
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
@@ -130,6 +132,7 @@ public class AgentInstaller {
.or(nameContains("javassist"))
.or(nameContains(".asm."))
.or(nameMatches("com\\.mchange\\.v2\\.c3p0\\..*Proxy"))
+ .or(hasAnnotation(annotationType(named("javax.decorator.Decorator"))))
.or(matchesConfiguredExcludes());
for (final AgentBuilder.Listener listener : listeners) {

ADD
dd-java-agent/instrumentation/cdi-1.2/cdi-1.2.gradle
+apply from: "${rootDir}/gradle/java.gradle"
+
+apply plugin: 'org.unbroken-dome.test-sets'
+
+testSets {
+ latestDepTest {
+ dirName = 'test'
+ }
+}
+
+dependencies {
+ testCompile project(':dd-java-agent:instrumentation:java-concurrent')
+
+ testCompile group: 'org.jboss.weld', name: 'weld-core', version: '2.3.0.Final'
+ testCompile group: 'org.jboss.weld.se', name: 'weld-se', version: '2.3.0.Final'
+ testCompile group: 'org.jboss.weld.se', name: 'weld-se-core', version: '2.3.0.Final'
+
+ // Beyond 2.x is CDI 2+ and requires Java 8
+ latestDepTestCompile group: 'org.jboss.weld', name: 'weld-core', version: '2.+'
+ latestDepTestCompile group: 'org.jboss.weld.se', name: 'weld-se', version: '2.+'
+ latestDepTestCompile group: 'org.jboss.weld.se', name: 'weld-se-core', version: '2.+'
+}

ADD
dd-java-agent/instrumentation/cdi-1.2/src/test/groovy/CDIContainerTest.groovy
+import datadog.trace.agent.test.AgentTestRunner
+import org.jboss.weld.environment.se.Weld
+import org.jboss.weld.environment.se.WeldContainer
+import org.jboss.weld.environment.se.threading.RunnableDecorator
+
+class CDIContainerTest extends AgentTestRunner {
+
+ def "CDI container starts with agent"() {
+ given:
+ Weld builder = new Weld()
+ .disableDiscovery()
+ .decorators(RunnableDecorator)
+
+ when:
+ WeldContainer container = builder.initialize()
+
+ then:
+ container.isRunning()
+
+ cleanup:
+ container?.shutdown()
+ }
+}

MODIFY
settings.gradle
settings.gradle
@@ -28,6 +28,7 @@ include ':dd-java-agent:instrumentation:apache-httpasyncclient-4'
include ':dd-java-agent:instrumentation:apache-httpclient-4'
include ':dd-java-agent:instrumentation:aws-java-sdk-1.11.0'
include ':dd-java-agent:instrumentation:aws-java-sdk-2.2'
+include ':dd-java-agent:instrumentation:cdi-1.2'
include ':dd-java-agent:instrumentation:couchbase-2.0'
include ':dd-java-agent:instrumentation:couchbase-2.6'
include ':dd-java-agent:instrumentation:datastax-cassandra-3'

Dont instrument `@Decorator`s or CDI breaks