OpenTelemetry: Add route id to the name of the actual root span
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 20.8k
- Forks
- 2.3k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 156
Description
Describe the problem
It is a very great thing that SvelteKit now has first-class support for OpenTelemetry, and it solves some problems we had in the past.
We use OpenTelemetry with the HTTP-Instrumentation (which is also included in the Auto-Instrumentation). Therefore, our root span is a span from this instrumentation, and for example, is named GET (the HTTP verb). In the past, we had a SvelteKit middleware that renamed this span and added the route id, for example, GET /(app)/some/route. This is part of the Semantic conventions for HTTP spans. The HTTP instrumentation cannot know the SvelteKit route id. Therefore, it must be updated later. For example, we need this information for better filtering and dashboard creation in Grafana.
But with the introduction of OpenTelemetry support in SvelteKit, I couldn't find a way to get a reference to the root span, to rename it myself. SvelteKit provides a root span in event.tracing.root, but this is only the first span that SvelteKit creates, and not the actual root span.
I've added a screenshot from one of our traces. The root span that is provided by SvelteKit is the sveltekit.handle.root span. We need to rename the topmost span GET to include the route id.
Describe the proposed solution
One possible solution would be that SvelteKit somehow provides the actual root span of the HTTP instrumentation.
Another solution could be that SvelteKit updates the name of the root span itself.
Alternatives considered
No response
Importance
would make my life easier
Additional Information
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with SvelteKit's event.tracing.root behavior and the HTTP instrumentation that creates the topmost GET span. Compare the proposed approaches—exposing the actual root span or renaming it—to determine the intended API, with completion indicated by the route id appearing in the root span name.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- observability-sre
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100