-
Notifications
You must be signed in to change notification settings - Fork 591
Open
Labels
bugSomething isn't workingSomething isn't workingpkg:instrumentation-graphqlpriority:p3Bugs which cause problems in user apps not related to correctness (performance, memory use, etc)Bugs which cause problems in user apps not related to correctness (performance, memory use, etc)
Description
What version of OpenTelemetry are you using?
"@opentelemetry/api": "^1.4.1"
What version of Node are you using?
v18.17.1
What did you do?
I enabled the auto instrumentation with ignoreTrivialResolveSpans
option enabled
new GraphQLInstrumentation({
ignoreTrivialResolveSpans: true
})
Expected:
What did you expect to see?
The resolves that don't have any custom implementation don't generate any span
What did you see instead?
All resolves generate a corresponding span
Additional context
Digging into Apollo's implementation, I found that when it loads its internal plugins, it always wraps the field.resolve
with a function that executes the default or the user-defined resolver, as you can see here:
For that reason, this condition:
opentelemetry-js-contrib/plugins/node/opentelemetry-instrumentation-graphql/src/utils.ts
Lines 327 to 329 in deb9aa4
if (field.resolve) { | |
field.resolve = wrapFieldResolver(tracer, getConfig, field.resolve); | |
} |
evaluates true for all resolvers (including the default ones) and always ends up instrumenting all field resolvers
zanemcca, bmbferreira, klippx, Manivela and marco2216
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingpkg:instrumentation-graphqlpriority:p3Bugs which cause problems in user apps not related to correctness (performance, memory use, etc)Bugs which cause problems in user apps not related to correctness (performance, memory use, etc)