Title: AsyncioIntegration breaks tracing inside ThreadPoolExecutor · Issue #4508 · getsentry/sentry-python · GitHub
Open Graph Title: AsyncioIntegration breaks tracing inside ThreadPoolExecutor · Issue #4508 · getsentry/sentry-python
X Title: AsyncioIntegration breaks tracing inside ThreadPoolExecutor · Issue #4508 · getsentry/sentry-python
Description: How do you use Sentry? Sentry Saas (sentry.io) Version 2.30.0 Steps to Reproduce Init Sentry with AsyncioIntegration. Create ThreadPoolExecutor Create async task using asyncio.create_task Inside the task call loop.run_in_executor Code to...
Open Graph Description: How do you use Sentry? Sentry Saas (sentry.io) Version 2.30.0 Steps to Reproduce Init Sentry with AsyncioIntegration. Create ThreadPoolExecutor Create async task using asyncio.create_task Inside th...
X Description: How do you use Sentry? Sentry Saas (sentry.io) Version 2.30.0 Steps to Reproduce Init Sentry with AsyncioIntegration. Create ThreadPoolExecutor Create async task using asyncio.create_task Inside th...
Opengraph URL: https://github.com/getsentry/sentry-python/issues/4508
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"AsyncioIntegration breaks tracing inside ThreadPoolExecutor","articleBody":"### How do you use Sentry?\n\nSentry Saas (sentry.io)\n\n### Version\n\n2.30.0\n\n### Steps to Reproduce\n\n1. Init Sentry with AsyncioIntegration. \n2. Create ThreadPoolExecutor\n3. Create async task using asyncio.create_task\n4. Inside the task call loop.run_in_executor\n\nCode to reproduce the issue:\n```python\nimport asyncio\nimport threading\nfrom concurrent.futures import ThreadPoolExecutor\nfrom time import sleep\nimport sentry_sdk\nfrom sentry_sdk.integrations.asyncio import AsyncioIntegration\n\n\ndef init_sentry():\n sentry_sdk.init(\n dsn=\"\",\n traces_sample_rate=1.0,\n integrations=[\n AsyncioIntegration(),\n ],\n )\n\n@sentry_sdk.trace\ndef task_1():\n print(f\"Task 1 thread ID: {threading.get_ident()}\")\n sleep(0.5)\n\nasync def main():\n init_sentry() \n print(f\"Main thread ID: {threading.get_ident()}\") \n executor = ThreadPoolExecutor()\n for i in range(3):\n task = asyncio.create_task(worker_task(executor, i))\n await task\n\nasync def worker_task(executor: ThreadPoolExecutor, i: int):\n with sentry_sdk.start_transaction(\n op=\"function\", name=\"main_thread\"\n ):\n print(f\"\\nWorker task {i} thread ID: {threading.get_ident()}\")\n loop = asyncio.get_event_loop()\n await loop.run_in_executor(executor, task_1)\n\n\nif __name__ == \"__main__\":\n asyncio.run(main()) \n```\n\n### Expected Result\n\nSpans created in tasks that run in a ThreadPoolExecutor should be included in the transactions sent to Sentry when `AsyncioIntegration` is enabled.\n\n### Actual Result\n\nSpans created in tasks that run in a ThreadPoolExecutor are missing from the transactions sent to Sentry.\n\nOnly the first execution contains all the spans:\n\n\nSubsequent executions are missing spans created inside executor:\n\n\nRemoving `AsyncioIntegration` integration solves the issue but then many automatic async related spans are missing. Our application uses asyncio but executes many CPU intensive blocking tasks inside executor.\n\nI also tried Sentry 3.0.0a2 and it has the same issue.\n","author":{"url":"https://github.com/ollipa","@type":"Person","name":"ollipa"},"datePublished":"2025-06-23T13:45:44Z","url":"https://github.com/getsentry/sentry-python/issues/4508"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a9486649-62c9-4129-4b98-5a0606a91edc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 978A:29E0EC:3A2878:4E42E3:6B008AE5 |
| html-safe-nonce | d838d2eaf1e23db9b2c21598df0103ea5aa68173a17dac95af799b029805ce86 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NzhBOjI5RTBFQzozQTI4Nzg6NEU0MkUzOjZCMDA4QUU1IiwidmlzaXRvcl9pZCI6IjEwMzI5NzczNzIwNjU4NjAzMjUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | dcd6bb295840250cd61bddfa6cef61548ada0dc14e9f413410507f566ac02a87 |
| hovercard-subject-tag | issue:3168272422 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-python/4508/issue_layout |
| twitter:image | https://opengraph.githubassets.com/df49efcc16ac59dc78bc56a8bb25f3e4cf1f69d63eac9bf69e917cccfdd20c0a/getsentry/sentry-python/issues/4508 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/df49efcc16ac59dc78bc56a8bb25f3e4cf1f69d63eac9bf69e917cccfdd20c0a/getsentry/sentry-python/issues/4508 |
| og:image:alt | How do you use Sentry? Sentry Saas (sentry.io) Version 2.30.0 Steps to Reproduce Init Sentry with AsyncioIntegration. Create ThreadPoolExecutor Create async task using asyncio.create_task Inside th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ollipa |
| hostname | github.com |
| expected-hostname | github.com |
| None | c710a5cb5c47be60abfe6e8410436d409906979dbed614ef09f29c60f5535b08 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-python git https://github.com/getsentry/sentry-python.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 137814779 |
| octolytics-dimension-repository_nwo | getsentry/sentry-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 137814779 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | be616a2a6ec1c609d6e002896dff5352d5c5f28b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width