GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — refactor: move FastAPI active thread tracking into Starlette by faizansaiyed123 · Pull Request #7825 · getsentry/sentry-python

Conversation

@faizansaiyed123

@faizansaiyed123 faizansaiyed123 commented Oct 2, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Ref #7753

This separates the active-thread/profiler bookkeeping from the FastAPI-specific request handling.

Changes:

  • Centralize active-thread updates in the Starlette integration.
  • Provide a Starlette sync-handler wrapper so active-thread metadata is updated in the thread that actually executes a synchronous handler.
  • Reuse that wrapper from the FastAPI integration.
  • Preserve both static transaction and span-streaming behavior.

The follow-up FastAPI PR uses this Starlette helper while replacing the private FastAPI request-handler patch with a global dependency.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
faizansaiyed123 added 3 commits October 2, 2026 08:44
@faizansaiyed123
refactor(starlette): centralize active thread updates
c5c2dfe
@faizansaiyed123
refactor(fastapi): use Starlette active thread helper
a14cd78
@faizansaiyed123
chore(fastapi): remove unused thread helper import
87d3a13
@faizansaiyed123
faizansaiyed123 requested a review from a team as a code owner October 2, 2026 03:15
cursor[bot]
cursor Bot reviewed Oct 2, 2026
View reviewed changes

@cursor cursor Bot left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 87d3a13. Configure here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread sentry_sdk/integrations/starlette.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@faizansaiyed123 faizansaiyed123 mentioned this pull request Oct 2, 2026
refactor(fastapi): use a global dependency for active thread tracking #7826
Open
faizansaiyed123 added 3 commits October 2, 2026 08:49
@faizansaiyed123
fix(starlette): preserve sync request scope access
7f93ff1
@faizansaiyed123
refactor(starlette): centralize sync thread wrapper
2a3964a
@faizansaiyed123
refactor(fastapi): use Starlette sync thread wrapper
3873552
sentrivana
sentrivana reviewed Oct 6, 2026
View reviewed changes

@sentrivana sentrivana left a comment

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Looks good to me, except for one attribute name, left a suggestion there.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread sentry_sdk/integrations/starlette.py Outdated
Comment on lines +652 to +660
if getattr(handler, "_sentry_active_thread_is_patched", False):
return handler

@functools.wraps(handler)
def _sentry_sync_handler(*args: "Any", **kwargs: "Any") -> "Any":
_update_active_thread()
return handler(*args, **kwargs)

_sentry_sync_handler._sentry_active_thread_is_patched = True # type: ignore[attr-defined]

@sentrivana sentrivana Oct 6, 2026

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Suggested change
if getattr(handler, "_sentry_active_thread_is_patched", False):
return handler
@functools.wraps(handler)
def _sentry_sync_handler(*args: "Any", **kwargs: "Any") -> "Any":
_update_active_thread()
return handler(*args, **kwargs)
_sentry_sync_handler._sentry_active_thread_is_patched = True # type: ignore[attr-defined]
if getattr(handler, "_sentry_patched", False):
return handler
@functools.wraps(handler)
def _sentry_sync_handler(*args: "Any", **kwargs: "Any") -> "Any":
_update_active_thread()
return handler(*args, **kwargs)
_sentry_sync_handler._sentry_patched = True # type: ignore[attr-defined]

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@faizansaiyed123
fix(starlette): use standard sentry patched attribute
8409daf
@faizansaiyed123
faizansaiyed123 requested a review from sentrivana October 6, 2026 13:46
sentrivana
sentrivana approved these changes Oct 7, 2026
View reviewed changes
@sentrivana
sentrivana enabled auto-merge (squash) October 7, 2026 08:01
@sentrivana
sentrivana merged commit 4b9d329 into getsentry:master Oct 7, 2026
161 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@sentry-release-bot sentry-release-bot Bot mentioned this pull request Oct 12, 2026
publish: getsentry/[email protected] getsentry/publish#9830
Closed
6 tasks done
@piotrsroka piotrsroka mentioned this pull request Nov 5, 2026
Clear the November dependency CVEs and unblock pytest 9.2 humane-intelligence/hi-oss-ai-red-teaming#28
Merged
7 of 8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@cursor cursor[bot] cursor[bot] left review comments
@sentrivana sentrivana sentrivana approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@faizansaiyed123 @sentrivana
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.