Skip to content

@envelop/opentelemetry resolver spans aren’t active, nested spans attach to operation span #2851

@kdawgwilk

Description

@kdawgwilk

Issue workflow progress

Progress of the issue based on the
Contributor Workflow


Describe the bug

When using useOpenTelemetry({ resolvers: true }), resolver spans are created but resolver execution is not run inside an active span context. As a result, nested spans created inside resolvers attach to the GraphQL operation span instead of the resolver span.

To Reproduce Steps to reproduce the behavior:

  1. Enable useOpenTelemetry with resolvers: true.
  2. Execute a GraphQL query whose resolvers call any instrumented library.
  3. Inspect traces (or run the StackBlitz repro).

Expected behavior

Nested spans created during resolver execution should be children of the resolver span, not the operation span.

Environment:

  • OS: macOS (darwin 24.6.0)
  • NodeJS: v24.11.1
  • @envelop/* versions:
    • @envelop/core: 5.5.0
    • @envelop/opentelemetry: 9.1.0
    • @envelop/on-resolve: 7.1.0

Additional context

The resolver span is created in the useOnResolve handler, but the resolver execution itself is not wrapped in an active span context (e.g. context.with(trace.setSpan(...)) / startActiveSpan), so downstream instrumentations don’t see the resolver span as active.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions