open-telemetry / open-telemetry/opentelemetry-python-contrib
Route included in metrics auto-instrumentation ASGI
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 1.1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 16
Description
There is a way to get the http.route included in autoinstrumented metrics for FastAPI?
Looking the following docs: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/semantic_conventions/http-metrics.md#parameterized-attributes
But the implementation of the recommended attributes doesn't include the http.route attribute:
Also the implementation of ASGI instrumentation, parse attributes for both metrics (duration and active_requests) after the addition of additional attributes (where the http.routes comes):
https://github.com/open-telemetry/opentelemetry-python-contrib/blob/3c24adf1b2c95bf8fdca7de146e38922ef9581fe/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py#L446-L450
Is your feature request related to a problem?
Maybe the inclusion of path or route attributes, could be usefull for metrics analysis.
Describe the solution you'd like
Move the additional attributes update in the ASGI instrumentation, after the call of recommended attributes for metrics.
Describe alternatives you've considered
Manually instrumentation of all paths in the API.
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 in instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/init.py around the metrics attribute handling, then review util/opentelemetry-util-http/src/opentelemetry/util/http/init.py and the linked HTTP metrics conventions. Confirm how additional attributes are added relative to recommended attributes, and verify that ASGI duration and active-request metrics include the route attribute without breaking existing behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- fastapi, python
- Domain
- observability
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100