Hi! 👋
This PR fixes an issue with dd-trace not able to track execution spans of graphql resolvers when using graphql-yoga v3.0.0+. The issue was introduced by this commit in graphql-yoga that changed the execution model of graphql queries: previously the executor of the graphql library was used (and that's what dd-trace instruments), while after that change the executor of the @graphql-tools/executor library is used (and dd-trace doesn't instrument it).
This PR adds instrumentation to the new executor.
Here is the diff that solved my problem:
diff --git a/node_modules/dd-trace/packages/datadog-instrumentations/src/graphql.js b/node_modules/dd-trace/packages/datadog-instrumentations/src/graphql.js
index 0bad6fc..933fe5b 100644
--- a/node_modules/dd-trace/packages/datadog-instrumentations/src/graphql.js
+++ b/node_modules/dd-trace/packages/datadog-instrumentations/src/graphql.js
@@ -349,6 +349,11 @@ function finishResolvers ({ fields }) {
})
}
+addHook({ name: '@graphql-tools/executor', file: 'cjs/execution/execute.js', versions: ['>=0.0.14'] }, execute => {
+ shimmer.wrap(execute, 'execute', wrapExecute(execute))
+ return execute
+ })
+
addHook({ name: 'graphql', file: 'execution/execute.js', versions: ['>=0.10'] }, execute => {
shimmer.wrap(execute, 'execute', wrapExecute(execute))
return execute
diff --git a/node_modules/dd-trace/packages/datadog-instrumentations/src/helpers/hooks.js b/node_modules/dd-trace/packages/datadog-instrumentations/src/helpers/hooks.js
index 840c98d..97080b0 100644
--- a/node_modules/dd-trace/packages/datadog-instrumentations/src/helpers/hooks.js
+++ b/node_modules/dd-trace/packages/datadog-instrumentations/src/helpers/hooks.js
@@ -36,6 +36,7 @@ module.exports = {
'fs': () => require('../fs'),
'node:fs': () => require('../fs'),
'graphql': () => require('../graphql'),
+ '@graphql-tools/executor': () => require('../graphql'),
'grpc': () => require('../grpc'),
'hapi': () => require('../hapi'),
'http': () => require('../http'),
This issue body was partially generated by patch-package.
Hi! 👋
This PR fixes an issue with
dd-tracenot able to track execution spans of graphql resolvers when usinggraphql-yogav3.0.0+. The issue was introduced by this commit ingraphql-yogathat changed the execution model of graphql queries: previously the executor of thegraphqllibrary was used (and that's whatdd-traceinstruments), while after that change the executor of the@graphql-tools/executorlibrary is used (anddd-tracedoesn't instrument it).This PR adds instrumentation to the new executor.
Here is the diff that solved my problem:
This issue body was partially generated by patch-package.