We're using graphql-jit by way of the fastifymercurius plugin. JIT-ing graphql queries creates V8-optimizable functions to increase performance.
When using mercurius, there's a jit parameter you can set to enable this functionality. By default, JIT-ing is disabled.
The Issue
After the jit occurs, we lose all the GraphQL spans reported to Datadog. This makes it difficult to analyze APM spans because we don't know what query is being executed.
You can also see that it's related to the jit process by setting the jit value here to different values. For instance, if you set it to 5 (JIT after 5 requests), you'll see the spans reported 5 times and on the 6th request, they disappear.
Comments
This generally makes sense why we're losing these spans. The optimizable functions aren't instrumented, so we lose the spans.
There's an outstanding request to support Mercurius (see https://github.com/DataDog/dd-trace-js/issues/1141). This happens to be how my client is enabling graphql-jit, but I believe this issue will occur for anyone using the graphql-jit package.
Workaround
In the meantime, I was able to capture the body of the request by adding a context method to the Mercurius config:
Background
We're using
graphql-jit
by way of thefastify
mercurius
plugin. JIT-ing graphql queries creates V8-optimizable functions to increase performance.When using
mercurius
, there's ajit
parameter you can set to enable this functionality. By default, JIT-ing is disabled.The Issue
After the
jit
occurs, we lose all the GraphQL spans reported to Datadog. This makes it difficult to analyze APM spans because we don't know what query is being executed.Reproduction Repository
I created a simple repo that shows this issue: https://github.com/blimmer/dd-trace-fastify-app
Setup:
To see things working with Jit turned off:
jit
parameter insrc/server.js
, or set the value to0
to disable it. https://github.com/blimmer/dd-trace-fastify-app/blob/3b73042d26779234a0e425d70703bf82128ddffa/src/server.js#L26yarn start
localhost:3000
to trigger a graphql query twiceYou'll notice in the dd-trace debug output that graphql spans are being reported on every request:
To see graphql spans being dropped after Jit is turned on
jit
parameter insrc/server.js
to1
: https://github.com/blimmer/dd-trace-fastify-app/blob/3b73042d26779234a0e425d70703bf82128ddffa/src/server.js#L26yarn start
localhost:3000
to trigger a graphql query twiceOn the first request, you'll see the graphql spans being reported:
But then on the second request (now that the query is JIT-ed), you'll see that no graphql spans are being reported:
You can also see that it's related to the
jit
process by setting thejit
value here to different values. For instance, if you set it to5
(JIT after 5 requests), you'll see the spans reported 5 times and on the 6th request, they disappear.Comments
graphql-jit
, but I believe this issue will occur for anyone using thegraphql-jit
package.Workaround
In the meantime, I was able to capture the body of the request by adding a
context
method to the Mercurius config:This at least allows me to see the query/mutation body, which is very helpful for debugging. Before this change, all I could see was
POST / graphql
.