Skip to content

set graphql.resolve span as the active span in scope when executing the resolve function#7624

Closed
lukiano wants to merge 1 commit into
DataDog:masterfrom
lukiano:graphql-resolve-scope
Closed

set graphql.resolve span as the active span in scope when executing the resolve function#7624
lukiano wants to merge 1 commit into
DataDog:masterfrom
lukiano:graphql-resolve-scope

Conversation

@lukiano

@lukiano lukiano commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Makes a change in the GraphQL instrumentation so that the active scope when executing a resolve function is the graphql.resolve span instead of the graphql.execute span.

Motivation

Currently, spans created in a GraphQL resolve function are children of graphql.execute and siblings of the graphql.resolve that belongs to the field being resolved. Therefore, the hierarchy doesn't appear to be correct in Datadog APM.

Additional Notes

There's likely a better way to do this, but I'm not familiar enough with the internals.

@lukiano
lukiano requested a review from a team as a code owner February 26, 2026 03:35
@BridgeAR BridgeAR self-assigned this Mar 17, 2026
BridgeAR added a commit that referenced this pull request May 26, 2026
`tracer.startSpan(...)` calls inside a graphql resolver parented under
`graphql.execute` instead of the field's `graphql.resolve` span, because the
resolve plugin populated `fieldCtx.currentStore` without entering it on
`storage('legacy')`. Migrate the resolve channel to the same `runStores` +
`bindStart` shape `wrapExecute` already uses in this file: the plugin's
`bindStart` returns the new store on first encounter, the parent ALS store on
depth/collapse-filtered fields, and the cached store when the same field is
revisited (collapsed list siblings).

`apm:graphql:resolve:start` subscribers (today: IAST taint-tracking) now fire
once per resolver invocation rather than once per field path. For non-collapsed
queries that is unchanged; for collapsed list fields it tags every sibling's
args instead of only the first.

Co-authored-by: Luciano Leggieri <[email protected]>
Refs: #7624
@dd-octo-sts

dd-octo-sts Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

This pull request has been marked as stale due to 90 days of inactivity.
If this is still relevant, please update or comment to keep it open.
If this should be kept open indefinitely, please apply the label keep-open.
Otherwise, it will be automatically closed after 14 days.

@dd-octo-sts dd-octo-sts Bot added the stale label Jun 16, 2026
@BridgeAR

Copy link
Copy Markdown
Member

@lukiano just a brief update: thank you for the PR! That definitely seems like something we should do. I wanted to include that after our OrchestrionJS rewrite which should land in about a week.

@dd-octo-sts dd-octo-sts Bot removed the stale label Jun 17, 2026
@BridgeAR

BridgeAR commented Jul 8, 2026

Copy link
Copy Markdown
Member

This got superseded and the fix is released in our latest version

@BridgeAR BridgeAR closed this Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants