Open
Description
What version of OpenTelemetry are you using?
@opentelemetry/api v 1.4.1
What version of Node are you using?
18.16.0
What did you do?
Create a GraphQL API (I'm using Apollo but I don't believe it matters) with a query, mutation, or a field on an individual type whose response type is a union, eg:
type Foo {
field: String
}
type Bar {
anotherField: String
}
union MyUnion = Foo | Bar
type Query {
fooOrBar: MyUnion!
}
Then execute a GraphQL query, eg:
{
fooOrBar {
...on Foo {
myField
}
...on Bar {
anotherField
}
}
}
What did you expect to see?
Resolve spans for each resolver that ran (eg. if a Foo
is returned, a span for fooOrBar
and myField
)
What did you see instead?
A single resolve span for the query field only (fooOrBar
). This is the case no matter how deeply the query nests.
Additional context
I'm using the node SDK to instrument automatically. I also made sure to set ignoreTrivialResponseSpans
to false
and depth
to -1
(I know they are defaulted, but I wanted to be sure it wasn't related) like so:
const sdk = new opentelemetry.NodeSDK({
// other settings...
instrumentations: [getNodeAutoInstrumentations({
'@opentelemetry/instrumentation-graphql': {
ignoreTrivialResolveSpans: false,
depth: -1,
},
})],
});