René's URL Explorer Experiment


Title: Sentry background worker is chronically blocking async event loop when many exceptions are raised · Issue #2824 · getsentry/sentry-python · GitHub

Open Graph Title: Sentry background worker is chronically blocking async event loop when many exceptions are raised · Issue #2824 · getsentry/sentry-python

X Title: Sentry background worker is chronically blocking async event loop when many exceptions are raised · Issue #2824 · getsentry/sentry-python

Description: How do you use Sentry? Self-hosted/on-premise Version 1.40.6 Steps to Reproduce Hello! And thanks for reading my ticket :) The python sentry client is a synchronous client library that is retrofitted to fit the async model (by spinning o...

Open Graph Description: How do you use Sentry? Self-hosted/on-premise Version 1.40.6 Steps to Reproduce Hello! And thanks for reading my ticket :) The python sentry client is a synchronous client library that is retrofitt...

X Description: How do you use Sentry? Self-hosted/on-premise Version 1.40.6 Steps to Reproduce Hello! And thanks for reading my ticket :) The python sentry client is a synchronous client library that is retrofitt...

Opengraph URL: https://github.com/getsentry/sentry-python/issues/2824

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Sentry background worker is chronically blocking async event loop when many exceptions are raised","articleBody":"### How do you use Sentry?\n\nSelf-hosted/on-premise\n\n### Version\n\n1.40.6\n\n### Steps to Reproduce\n\nHello! And thanks for reading my ticket :) \r\n\r\nThe python sentry client is a synchronous client library that is retrofitted to fit the async model (_by spinning off separate threads to avoid disrupting the event loop thread_ -- _see background worker (1) for thread usage_).\r\n\r\nUnder healthy conditions, the sentry client doesn’t need to make many web requests. However, if conditions become rocky and exceptions are frequently raised (_caught or uncaught_), the sentry client may become an extreme inhibitor to the app event loop (_assuming high sample rate_). This is due to the necessary OS thread context switching that effectively pauses/blocks the event loop to work on other threads (_i.e the background worker (1)_). This is not a recommended pattern (_obviously_) due to the costs of switching threads, but can be useful for quickly/lazily retrofitting sync code.\r\n\r\nRelevant flow - in short:\r\nEvery time an exception is raised (_caught or uncaught_) in my code, a web request is immediately made to dump the data to sentry when sampled. Since sentry’s background worker is thread based (1), this will trigger an thread context switch and then a synchronous web request to dump the data to sentry. When applications receive many exceptions in a short period of time, this becomes a context switching nightmare.\r\n\r\nSuggestion:\r\nIn an ideal world, sentry would asyncify its Background worker to use a task (1) and its transport layer (2) would use aiohttp. I don't think this is of super high complexity, but I could be wrong.\r\n\r\nAn immediate workaround could be made with more background worker control. If sentry’s background worker made web requests to dump data at configurable intervals, it would behave far more efficiently for event loops apps. At the moment, the background worker always dumps data **immediately** with regards to exceptions. In my opinion, if sentry is flushing data at app exit, having a 60 second timer to dump data would alleviate most of the symptoms I described above without ever losing data (albeit it would be up to 60 seconds slower).\r\n\r\n(1) - https://github.com/getsentry/sentry-python/blob/1b0e932c3f827c681cdd20abfee9afc55e5d141c/sentry_sdk/worker.py#L20\r\n\r\n(2) - https://github.com/getsentry/sentry-python/blob/1b0e932c3f827c681cdd20abfee9afc55e5d141c/sentry_sdk/transport.py#L244\n\n### Expected Result\n\nI expect to have less thread context switching when using sentry.\n\n### Actual Result\n\nI see a lot of thread context switching when there are high exception rates.","author":{"url":"https://github.com/cpvandehey","@type":"Person","name":"cpvandehey"},"datePublished":"2024-03-14T22:59:54.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":19},"url":"https://github.com/2824/sentry-python/issues/2824"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:55484b79-6178-905f-aa28-c70023d81243
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id864C:37F343:A4ECE1:DE2488:6A4D728C
html-safe-nonceab6fa11f0dcb267ff357b60d7ce0881e07cd377b00d49f387e8c5c4b0a90da07
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NjRDOjM3RjM0MzpBNEVDRTE6REUyNDg4OjZBNEQ3MjhDIiwidmlzaXRvcl9pZCI6IjIyMTUwOTcyOTY5OTQ3OTIwNzYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac8ecec7c426d29ead0a5355d5d91a32e5bebb75510c3f33cc0d060c3544aac120
hovercard-subject-tagissue:2187420855
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-python/2824/issue_layout
twitter:imagehttps://opengraph.githubassets.com/d1c4a4f40fb875edab0cba39773986abf4d0f704944a11ecbb377a75d40df7b3/getsentry/sentry-python/issues/2824
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/d1c4a4f40fb875edab0cba39773986abf4d0f704944a11ecbb377a75d40df7b3/getsentry/sentry-python/issues/2824
og:image:altHow do you use Sentry? Self-hosted/on-premise Version 1.40.6 Steps to Reproduce Hello! And thanks for reading my ticket :) The python sentry client is a synchronous client library that is retrofitt...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamecpvandehey
hostnamegithub.com
expected-hostnamegithub.com
Nonec78260c7b3f4ac4b0356c8208537f05406a3a2d46a9ec3f735b372dcc519c39e
turbo-cache-controlno-preview
go-importgithub.com/getsentry/sentry-python git https://github.com/getsentry/sentry-python.git
octolytics-dimension-user_id1396951
octolytics-dimension-user_logingetsentry
octolytics-dimension-repository_id137814779
octolytics-dimension-repository_nwogetsentry/sentry-python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id137814779
octolytics-dimension-repository_network_root_nwogetsentry/sentry-python
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release399fff412f48461d435721c009efc17ea44be72f
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/getsentry/sentry-python/issues/2824#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgetsentry%2Fsentry-python%2Fissues%2F2824
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgetsentry%2Fsentry-python%2Fissues%2F2824
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=getsentry%2Fsentry-python
Reloadhttps://github.com/getsentry/sentry-python/issues/2824
Reloadhttps://github.com/getsentry/sentry-python/issues/2824
Reloadhttps://github.com/getsentry/sentry-python/issues/2824
Please reload this pagehttps://github.com/getsentry/sentry-python/issues/2824
getsentry https://github.com/getsentry
sentry-pythonhttps://github.com/getsentry/sentry-python
Notifications https://github.com/login?return_to=%2Fgetsentry%2Fsentry-python
Fork 637 https://github.com/login?return_to=%2Fgetsentry%2Fsentry-python
Star 2.2k https://github.com/login?return_to=%2Fgetsentry%2Fsentry-python
Code https://github.com/getsentry/sentry-python
Issues 362 https://github.com/getsentry/sentry-python/issues
Pull requests 48 https://github.com/getsentry/sentry-python/pulls
Discussions https://github.com/getsentry/sentry-python/discussions
Actions https://github.com/getsentry/sentry-python/actions
Security and quality 2 https://github.com/getsentry/sentry-python/security
Insights https://github.com/getsentry/sentry-python/pulse
Code https://github.com/getsentry/sentry-python
Issues https://github.com/getsentry/sentry-python/issues
Pull requests https://github.com/getsentry/sentry-python/pulls
Discussions https://github.com/getsentry/sentry-python/discussions
Actions https://github.com/getsentry/sentry-python/actions
Security and quality https://github.com/getsentry/sentry-python/security
Insights https://github.com/getsentry/sentry-python/pulse
Sentry background worker is chronically blocking async event loop when many exceptions are raisedhttps://github.com/getsentry/sentry-python/issues/2824#top
Better Async Supporthttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Better%20Async%20Support%22
Component: SDK CoreDealing with the core of the SDKhttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Component%3A%20SDK%20Core%22
Component: TransportDealing with the transporthttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Component%3A%20Transport%22
Improvementhttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Improvement%22
PythonSDKhttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Python%22
https://github.com/cpvandehey
cpvandeheyhttps://github.com/cpvandehey
on Mar 14, 2024https://github.com/getsentry/sentry-python/issues/2824#issue-2187420855
sentry-python/sentry_sdk/worker.pyhttps://github.com/getsentry/sentry-python/blob/1b0e932c3f827c681cdd20abfee9afc55e5d141c/sentry_sdk/worker.py#L20
1b0e932https://github.com/getsentry/sentry-python/commit/1b0e932c3f827c681cdd20abfee9afc55e5d141c
sentry-python/sentry_sdk/transport.pyhttps://github.com/getsentry/sentry-python/blob/1b0e932c3f827c681cdd20abfee9afc55e5d141c/sentry_sdk/transport.py#L244
1b0e932https://github.com/getsentry/sentry-python/commit/1b0e932c3f827c681cdd20abfee9afc55e5d141c
Better Async Supporthttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Better%20Async%20Support%22
Component: SDK CoreDealing with the core of the SDKhttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Component%3A%20SDK%20Core%22
Component: TransportDealing with the transporthttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Component%3A%20Transport%22
Improvementhttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Improvement%22
PythonSDKhttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Python%22
GitHub Issues with 👀 2https://github.com/orgs/getsentry/projects/190
GitHub Issues with 👀 3https://github.com/orgs/getsentry/projects/227
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.