Skip to content

feat(fastapi): Add http.route attribute - #7322

Merged
alexander-alderman-webb merged 6 commits into
masterfrom
webb/fastapi/http-route
Sep 2, 2026
Merged

feat(fastapi): Add http.route attribute#7322
alexander-alderman-webb merged 6 commits into
masterfrom
webb/fastapi/http-route

Conversation

@alexander-alderman-webb

@alexander-alderman-webb alexander-alderman-webb commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Description

Set the http.route attribute on the ASGI server span in patches for FastAPI endpoints.

Add the _server_segment_span field on the Scope class so HTTP framework integrations have a reference to the server span. The reference is used to set the parametrized route as the http.route attribute.

Issues

Reminders

Comment thread sentry_sdk/integrations/fastapi.py Outdated
Comment thread sentry_sdk/integrations/fastapi.py Outdated
Comment thread sentry_sdk/scope.py Outdated
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

125599 passed | ⏭️ 6763 skipped | Total: 132362 | Pass Rate: 94.89% | Execution Time: 451m 47s

📊 Comparison with Base Branch

Metric Change
Total Tests 📈 +692
Passed Tests 📈 +696
Failed Tests 📉 -4
Skipped Tests

➖ Removed Tests (4)

View removed tests
  • test_cache_spans_decorator[True]
    • File: tests.integrations.django.test_cache_module
  • test_continuous_profiler_auto_start_and_stop_sampled[experiment-thread]
    • File: tests.profiler.test_continuous_profiler
  • test_continuous_profiler_auto_start_and_stop_sampled[non-experiment-gevent]
    • File: tests.profiler.test_continuous_profiler
  • test_continuous_profiler_auto_start_and_stop_sampled_span_streaming[experiment-thread]
    • File: tests.profiler.test_continuous_profiler

All tests are passing successfully.

✅ Patch coverage is 95.65%. Project has 2492 uncovered lines.
✅ Project coverage is 90.29%. Comparing base (base) to head (head).

Files with missing lines (2)
File Patch % Lines
sentry_sdk/integrations/fastapi.py 100.00% ⚠️ 3 partials
sentry_sdk/integrations/asgi.py 50.00% ⚠️ 1 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    90.27%    90.29%    +0.02%
==========================================
  Files          193       193         —
  Lines        25649     25658        +9
  Branches      9454      9454         —
==========================================
+ Hits         23153     23166       +13
- Misses        2496      2492        -4
- Partials      1443      1444        +1

Generated by Codecov Action

Comment thread sentry_sdk/integrations/fastapi.py Outdated
@alexander-alderman-webb
alexander-alderman-webb marked this pull request as ready for review September 2, 2026 08:18
@alexander-alderman-webb
alexander-alderman-webb requested a review from a team as a code owner September 2, 2026 08:18
@alexander-alderman-webb alexander-alderman-webb changed the title feat(fastapi): Add http.route attribute feat(fastapi): Add http.route attribute Sep 2, 2026

@sentrivana sentrivana left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other ASGI integrations to follow? (And WSGI?)

@alexander-alderman-webb

Copy link
Copy Markdown
Contributor Author

Yes, tackling them now

@alexander-alderman-webb
alexander-alderman-webb merged commit 5c83554 into master Sep 2, 2026
144 checks passed
@alexander-alderman-webb
alexander-alderman-webb deleted the webb/fastapi/http-route branch September 2, 2026 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants