feat(instrumentation-graphql): Add option to put all resolve spans under the same parent span #3085
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Which problem is this PR solving?
At the moment, GraphQL "resolve" spans (spans generated for each resolver/sub-resolver in a GraphQL request) are generated in a tree structure that reflects the GraphQL resolution tree. This sounds great in theory, but in practice it generates this kind of traces, where child spans start when their parent spans end.
Although it may look fine at a glance, it has issues:
Collapsing a span with child spans in a trace viewer (maybe some of them handle this better?) results in some amount of time seemingly unaccounted for in the root span. E.g.:
Critical path in viewers like Jaeger does not generate properly
Short description of the changes
The solution is to never have a span end before all its child spans have ended. I can imagine two ways to achieve this:
Add an extra layer of spans for the tree structure, and put the "resolve" spans under their tree structure node.
Put all "resolve" spans under the same parent.
This PR implements option 2. for simplicity, although I am open to work toward option 1. if preferred.