Skip to content

Multiple root transactions have been found with this trace ID. #12000

Closed
@MoSattler

Description

@MoSattler

Is there an existing issue for this?

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

https://nevados.sentry.io/performance/trace/9c985546981349e086455fec5921a7c3/?node=trace-root&statsPeriod=15m&timestamp=1715607533&traceView=1

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

Screenshot 2024-05-13 at 15 50 31

Metadata

Metadata

Assignees

No one assigned

    Labels

    Package: nodeIssues related to the Sentry Node SDK

    Type

    Projects

    Status

    Waiting for: Product Owner

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions