forked from DataDog/dd-trace-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
1,617 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
apply from: "$rootDir/gradle/java.gradle" |
16 changes: 7 additions & 9 deletions
16
...umentation/graphql-java-14.0/build.gradle → ...aphql-java/graphql-java-14.0/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,25 @@ | ||
|
||
muzzle { | ||
pass { | ||
group = "com.graphql-java" | ||
module = 'graphql-java' | ||
versions = '[14.0,21)' | ||
versions = '[14.0,20)' | ||
assertInverse = true | ||
skipVersions = ['230521-nf-execution', 'vTEST'] | ||
// earlier versions are missing some classes and will require separate instrumentation | ||
} | ||
fail { | ||
group = "com.graphql-java" | ||
module = 'graphql-java' | ||
versions = '[1.2,14.0)' | ||
} | ||
} | ||
|
||
apply from: "$rootDir/gradle/java.gradle" | ||
|
||
addTestSuiteForDir('latestDepTest', 'test') | ||
addTestSuiteExtendingForDir('latestDepForkedTest', 'latestDepTest', 'test') | ||
|
||
dependencies { | ||
compileOnly group: 'com.graphql-java', name: 'graphql-java', version: '14.0' | ||
testImplementation group: 'com.graphql-java', name: 'graphql-java', version: '14.0' | ||
implementation project(':dd-java-agent:instrumentation:graphql-java:graphql-java-common') | ||
|
||
testImplementation group: 'com.graphql-java', name: 'graphql-java', version: '14.0' | ||
testImplementation project(':dd-java-agent:instrumentation:trace-annotation') | ||
|
||
latestDepTestImplementation group: 'com.graphql-java', name: 'graphql-java', version: '[19+,21)' | ||
latestDepTestImplementation group: 'com.graphql-java', name: 'graphql-java', version: '19.+' | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
...src/main/java/datadog/trace/instrumentation/graphqljava14/GraphQLJavaInstrumentation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package datadog.trace.instrumentation.graphqljava14; | ||
|
||
import static datadog.trace.agent.tooling.bytebuddy.matcher.ClassLoaderMatchers.hasClassNamed; | ||
import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.named; | ||
import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.namedOneOf; | ||
import static net.bytebuddy.matcher.ElementMatchers.isMethod; | ||
import static net.bytebuddy.matcher.ElementMatchers.not; | ||
import static net.bytebuddy.matcher.ElementMatchers.returns; | ||
|
||
import com.google.auto.service.AutoService; | ||
import datadog.trace.agent.tooling.Instrumenter; | ||
import datadog.trace.agent.tooling.InstrumenterModule; | ||
import graphql.execution.ValueUnboxer; | ||
import graphql.execution.instrumentation.Instrumentation; | ||
import net.bytebuddy.asm.Advice; | ||
import net.bytebuddy.matcher.ElementMatcher; | ||
|
||
@AutoService(InstrumenterModule.class) | ||
public class GraphQLJavaInstrumentation extends InstrumenterModule.Tracing | ||
implements Instrumenter.ForSingleType { | ||
|
||
public GraphQLJavaInstrumentation() { | ||
super("graphql-java"); | ||
} | ||
|
||
@Override | ||
public String instrumentedType() { | ||
return "graphql.GraphQL"; | ||
} | ||
|
||
@Override | ||
public String[] helperClassNames() { | ||
return new String[] { | ||
"datadog.trace.instrumentation.graphqljava.GraphQLDecorator", | ||
"datadog.trace.instrumentation.graphqljava.ParsingInstrumentationContext", | ||
"datadog.trace.instrumentation.graphqljava.ExecutionInstrumentationContext", | ||
"datadog.trace.instrumentation.graphqljava.ValidationInstrumentationContext", | ||
"datadog.trace.instrumentation.graphqljava.State", | ||
packageName + ".GraphQLInstrumentation", | ||
"datadog.trace.instrumentation.graphqljava.GraphQLQuerySanitizer", | ||
"datadog.trace.instrumentation.graphqljava.InstrumentedDataFetcher" | ||
}; | ||
} | ||
|
||
@Override | ||
public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() { | ||
// introduced in 20.0 | ||
return not(hasClassNamed("graphql.execution.instrumentation.SimplePerformantInstrumentation")); | ||
} | ||
|
||
@Override | ||
public void methodAdvice(MethodTransformer transformer) { | ||
transformer.applyAdvice( | ||
isMethod() | ||
.and( | ||
namedOneOf( | ||
"checkInstrumentationDefaultState" // 9.7+ | ||
// https://github.com/graphql-java/graphql-java/commit/821241de8ee055d6d254a9d95ef5143f9e540826 | ||
// "checkInstrumentation" // <9.7 | ||
// https://github.com/graphql-java/graphql-java/commit/78a6e4eda1c13f47573adb879ae781cce794e96a | ||
)) | ||
.and(returns(named("graphql.execution.instrumentation.Instrumentation"))), | ||
this.getClass().getName() + "$AddInstrumentationAdvice"); | ||
} | ||
|
||
@SuppressWarnings("unused") | ||
public static class AddInstrumentationAdvice { | ||
@Advice.OnMethodExit(suppress = Throwable.class) | ||
public static void onExit(@Advice.Return(readOnly = false) Instrumentation instrumentation) { | ||
instrumentation = GraphQLInstrumentation.install(instrumentation); | ||
} | ||
|
||
public static void muzzleCheck() { | ||
// Class introduced in 15.0 | ||
ValueUnboxer value = ValueUnboxer.DEFAULT; | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...est/groovy/GraphQLInstallationTest.groovy → ...est/groovy/GraphQLInstallationTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
52 changes: 52 additions & 0 deletions
52
dd-java-agent/instrumentation/graphql-java/graphql-java-20.0/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
ext { | ||
latestDepTestMinJavaVersionForTests = JavaVersion.VERSION_11 | ||
latestDepForkedTestMinJavaVersionForTests = JavaVersion.VERSION_11 | ||
} | ||
// there are a lot of invalid version using dates (i.e. com.graphql-java-graphql-java-2018-06-04T04-23-07) | ||
// so we limit by chunks | ||
muzzle { | ||
pass { | ||
group = "com.graphql-java" | ||
module = 'graphql-java' | ||
versions = '[20.0, 21.0)' | ||
} | ||
} | ||
muzzle { | ||
pass { | ||
group = "com.graphql-java" | ||
module = 'graphql-java' | ||
versions = '[21.0, 22.0)' | ||
javaVersion = '11' | ||
} | ||
} | ||
muzzle { | ||
pass { | ||
group = "com.graphql-java" | ||
module = 'graphql-java' | ||
versions = '[22.0, 23.0)' | ||
javaVersion = '11' | ||
} | ||
} | ||
|
||
apply from: "$rootDir/gradle/java.gradle" | ||
|
||
addTestSuiteForDir('latestDepTest', 'test') | ||
addTestSuiteExtendingForDir('latestDepForkedTest', 'latestDepTest', 'test') | ||
|
||
dependencies { | ||
compileOnly group: 'com.graphql-java', name: 'graphql-java', version: '20.0' | ||
implementation project(':dd-java-agent:instrumentation:graphql-java:graphql-java-common') | ||
|
||
testImplementation group: 'com.graphql-java', name: 'graphql-java', version: '20.0' | ||
// to test collisions with other instrumentation | ||
testRuntimeOnly project(':dd-java-agent:instrumentation:graphql-java:graphql-java-14.0') | ||
testImplementation project(':dd-java-agent:instrumentation:trace-annotation') | ||
|
||
latestDepTestImplementation group: 'com.graphql-java', name: 'graphql-java', version: '20+,23)' | ||
|
||
[compileLatestDepTestJava, compileLatestDepForkedTestGroovy].each { | ||
it.configure { | ||
setJavaVersion(it, 11) | ||
} | ||
} | ||
} |
Oops, something went wrong.