Add option to nest `useOpenTelemetry` resolver spans by field path
Is your feature request related to a problem? Please describe.
Currently every resolver span created by useOpenTelemetry({ resolvers: true }) gets parented directly under the top-level operation span, regardless of how deep the field actually is in the query.
So for something like:
query {
user(id: "1") {
posts {
comments {
author { name }
}
}
}
}User.posts, Post.comments, Comment.author, and Author.name all end up as direct siblings under query, instead of a chain that reflects the actual resolution tree.
The old @opentelemetry/instrumentation-graphql defaults to tree-shaped nesting, with a config flag called flatResolveSpans to opt out into flat behavior. They achieved this by tracking spans in a map keyed by the field's info.path, and walking that path backwards to find the nearest ancestor that already had a span.
Describe the solution you'd like
An option to enable tree-shaped nested spans.
Source: graphql-hive/graphql-yoga