Closed
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/node
SDK Version
7.114.0
Framework Version
No response
Link to Sentry event
SDK Setup
Sentry.init({
dsn: 'xxx',
environment: 'local',
tracesSampleRate: 1.0,
})
Steps to Reproduce
I am using Fastify and Mercurius. Due to how these work, I am using custom instrumentation in their hooks.
fp(async (fastify) => {
fastify.graphql.addHook('preParsing', async (schema, document, context) => {
const queryName = getQueryName(document)
const span = Sentry.startInactiveSpan({
name: queryName,
op: 'graphql'
})
context.sentry = {
span
}
})
fastify.graphql.addHook('onResolution', async (execution, context) => {
context.sentry.span?.end()
})
const fields = getFields(fastify.graphql.schema)
resolvers.forEach((field) => {
field.resolver = (...args) => {
const context = args[2]
return Sentry.withActiveSpan(context.sentry.span, () =>
Sentry.startSpan(
{
op: 'graphql.resolve',
onlyIfParent: true,
name: field.name,
},
async () => await field.resolver(...args)
)
)
}
})
})
I don't use Sentry anywhere else.
Expected Result
Each transaction should have their own trace id. But for some reason, all the transactions share the same trace id. The documentation mentions that this can only happen if I set the trace id manually, but this is not the case.
Actual Result
Metadata
Metadata
Assignees
Type
Projects
Status
Waiting for: Product Owner