Repository navigation
Conversation
Assisted-by: OpenAI Codex
Assisted-by: OpenAI Codex
Pull request dashboard statusWaiting on the author · refreshed 2026-11-01 16:55 UTC Respond to 1 review item (e.g. link a commit, explain why not, ask a follow-up):
Status above doesn't look right?
|
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Host-routed WebSocket connections lose their server span name because their scopes lack a method, requiring a scope-type fallback and a regression test.
1 open issue
What changed in this PR
This PR addresses #5275 by preventing Starlette instrumentation from using raw request paths as http.route when a matched route has no path template.
Changes:
- Omit unavailable route attributes and use the HTTP method as the fallback span name.
- Add a regression test for host-routed HTTP requests.
- Document the fix in the changelog.
| File | Description |
|---|---|
instrumentation/opentelemetry-instrumentation-starlette/tests/test_starlette_instrumentation.py |
Verify host routing omits http.route and uses GET as the span name. |
instrumentation/opentelemetry-instrumentation-starlette/src/opentelemetry/instrumentation/starlette/__init__.py |
Remove the raw request path fallback for routes without a template. |
.changelog/5276.fixed |
Record the route-attribute fix. |
Review effort: Balanced
| except AttributeError: | ||
| # routes added via host routing won't have a path attribute | ||
| route = scope.get("path") | ||
| route = None |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Description
Omit
http.routewhen the matched Starlette route has no path template instead of using the raw request path. Host-routed spans fall back to the HTTP method as their name.Per HTTP semantic conventions:
Fixes #5275
Type of change
Validation: 67 tests passed with Starlette 0.13.8 and 67 with 0.46.2; Ruff lint/format and Pylint passed.
Checklist:
tox -e precommittox -e typecheck