Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip @Decorator classes when instrumenting #1045

Merged
merged 3 commits into from
Oct 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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;
Expand Down Expand Up @@ -130,6 +131,7 @@ public static ResettableClassFileTransformer installBytebuddyAgent(
.or(nameContains("javassist"))
.or(nameContains(".asm."))
.or(nameMatches("com\\.mchange\\.v2\\.c3p0\\..*Proxy"))
.or(isAnnotatedWith(named("javax.decorator.Decorator")))
.or(matchesConfiguredExcludes());

for (final AgentBuilder.Listener listener : listeners) {
Expand Down
22 changes: 22 additions & 0 deletions dd-java-agent/instrumentation/cdi-1.2/cdi-1.2.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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.+'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
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

class CDIContainerTest extends AgentTestRunner {

def "CDI container starts with agent"() {
given:
Weld builder = new Weld()
.disableDiscovery()
.addDecorator(RunnableDecorator)
.addBeanClass(TestBean)

when:
WeldContainer container = builder.initialize()

then:
container.isRunning()

cleanup:
container?.shutdown()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package datadog.trace.instrumentation;

public class TestBean {

private String someField;

public String getSomeField() {
return someField;
}

public void setSomeField(final String someField) {
this.someField = someField;
}
}
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down