Title: Migrate all integrations to span first · Issue #5386 · getsentry/sentry-python · GitHub
Open Graph Title: Migrate all integrations to span first · Issue #5386 · getsentry/sentry-python
X Title: Migrate all integrations to span first · Issue #5386 · getsentry/sentry-python
Description: As long as an integration interacts with tracing in some way (either creates spans on its own, or enriches existing spans with data), it needs to be migrated. If an integration doesn't do anything tracing-related, e.g. because it's error...
Open Graph Description: As long as an integration interacts with tracing in some way (either creates spans on its own, or enriches existing spans with data), it needs to be migrated. If an integration doesn't do anything ...
X Description: As long as an integration interacts with tracing in some way (either creates spans on its own, or enriches existing spans with data), it needs to be migrated. If an integration doesn't do anyth...
Opengraph URL: https://github.com/getsentry/sentry-python/issues/5386
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Migrate all integrations to span first","articleBody":"As long as an integration interacts with tracing in some way (either creates spans on its own, or enriches existing spans with data), it needs to be migrated.\n\nIf an integration doesn't do anything tracing-related, e.g. because it's errors-only, feel free to just close the related issue.\n\n⚠️ Careful though with stuff like event processors or tags — even if the integration doesn't appear to be interacting with tracing directly, some mechanisms still put stuff on the transaction, and that data should be ported to appear on the segment span in streaming mode.\n\n## Goal\n\n* The integration sends transactions without breaking anything in non-streaming (legacy) mode\n* In streaming mode, the integration uses the new v2 format and streams spans\n* The data on the spans is comparable in both modes\n* Any span attributes set by the integration follow our semantic conventions\n* Tests test the integration in both legacy and streaming mode and pass in both modes\n\n## How to migrate\n\n* As the core logic is now merged, open a feature branch against `master`.\n* You can check whether you're currently in legacy or streaming mode via`has_span_streaming_enabled` from `tracing_utils`.\n* All `start_span` calls have to be duplicated. In legacy mode, preserve old functionality. In streaming mode, use `sentry_sdk.traces.start_span` with the new signature. Make sure to migrate starting data like `op`, `origin` to starting attributes (`sentry.op`).\n * `start_transaction` calls need to migrated in a similar fashion. When migrating `start_transaction` calls, use `sentry_sdk.traces.start_span` with `parent_span=None` to explicitly force a segment.\n* Keep existing `continue_trace` usage for legacy mode. In streaming mode, use the new `sentry_sdk.traces.continue_trace` that's not a context manager.\n* Migrate `custom_sampling_context`. It should use `Scope.set_custom_sampling_context` in streaming mode.\n * Make sure it's set before the span is created as that's when it'll be sampled (and when custom sampling context needs to be available in the traces sampler).\n * Make sure it's set after `continue_trace`, as that wipes the propagation context that we use to store the custom sampling context.\n* Keep any event processors as they are, as they're still needed for event-based telemetry like errors. In streaming mode, make sure equivalent data is set on the span directly.\n * Avoid setting integration-level attributes on the scope via `scope.set_attribute`, as it'd then also be applied to metrics and logs as well as any children of the current span. See [https://develop.sentry.dev/sdk/telemetry/spans/span-protocol/#common-attribute-keys](\u003chttps://develop.sentry.dev/sdk/telemetry/spans/span-protocol/#common-attribute-keys>) for what attributes should be set on all spans. Other attributes should NOT be set on all spans. For instance, request related attributes should only be set on the segment span.\n* When translating old contexts, data, tags etc. to span attributes, follow Sentry conventions. If anything is unclear or there's an attribute missing, raise on Slack in `#proj-span-first-sentry` as product folks also need to be aligned on attribute changes.\n * Keep track of removed data/tags to call out later in the changelog.\n* Parametrize all tests that deal with tracing to execute both in legacy and in span streaming mode. Add equivalent assertions in streaming mode. You can use the `capture_items` fixture for unwrapping envelope item items automatically.\n* Some integrations (HTTP clients and DB) attach source information and they do it after a span has finished. In streaming mode, we can't set anything on a span after it's finished since it'll already be queued up for sending. So in that case, we need to do any sort of time measurements (to see if the span meets the length threshold to attach source data) as well as data attaching while the span is still alive.\n\nThere is also a comprehensive migration guide: [https://sentry-docs-git-ivana-span-first-migration-guide.sentry.dev/platforms/python/migration/span-first/](\u003chttps://sentry-docs-git-ivana-span-first-migration-guide.sentry.dev/platforms/python/migration/span-first/>)\n\n## Prototypes\n\n* Look at [ASGI](\u003chttps://github.com/getsentry/sentry-python/blob/master/sentry_sdk/integrations/asgi.py>), [WSGI](\u003chttps://github.com/getsentry/sentry-python/blob/master/sentry_sdk/integrations/wsgi.py>), or [Celer](\u003chttps://github.com/getsentry/sentry-python/blob/master/sentry_sdk/integrations/celery/__init__.py>)[y](\u003chttps://github.com/getsentry/sentry-python/blob/master/sentry_sdk/integrations/asgi.py>)\n* The original span first branch (unused now) has a few quick ports that are probably not 100% there but can be used as a reference: [https://github.com/getsentry/sentry-python/pull/5551/changes](\u003chttps://github.com/getsentry/sentry-python/pull/5551/changes>)\n\n## List of integrations\n\n### Prioritize\n\nThese appear to be used in Seer. Let's start with them to be able to dogfood Seer again soon.\n\n- [x] [https://github.com/getsentry/sentry-python/issues/5998](\u003chttps://github.com/getsentry/sentry-python/issues/5998>)\n- [X] [https://github.com/getsentry/sentry-python/issues/6001](\u003chttps://github.com/getsentry/sentry-python/issues/6001>)\n- [X] [https://github.com/getsentry/sentry-python/issues/6004](\u003chttps://github.com/getsentry/sentry-python/issues/6004>)\n- [X] [https://github.com/getsentry/sentry-python/issues/6009](\u003chttps://github.com/getsentry/sentry-python/issues/6009>)\n- [X] [https://github.com/getsentry/sentry-python/issues/6014](\u003chttps://github.com/getsentry/sentry-python/issues/6014>)\n- [X] [https://github.com/getsentry/sentry-python/issues/6017](\u003chttps://github.com/getsentry/sentry-python/issues/6017>)\n- [X] [https://github.com/getsentry/sentry-python/issues/6020](\u003chttps://github.com/getsentry/sentry-python/issues/6020>)\n- [X] [https://github.com/getsentry/sentry-python/issues/6028](\u003chttps://github.com/getsentry/sentry-python/issues/6028>)\n- [X] [https://github.com/getsentry/sentry-python/issues/6030](\u003chttps://github.com/getsentry/sentry-python/issues/6030>)\n- [X] [https://github.com/getsentry/sentry-python/issues/6036](\u003chttps://github.com/getsentry/sentry-python/issues/6036>)\n- [X] [https://github.com/getsentry/sentry-python/issues/6038](\u003chttps://github.com/getsentry/sentry-python/issues/6038>)\n- [X] [https://github.com/getsentry/sentry-python/issues/6039](\u003chttps://github.com/getsentry/sentry-python/issues/6039>)\n- [X] [https://github.com/getsentry/sentry-python/issues/6052](\u003chttps://github.com/getsentry/sentry-python/issues/6052>)\n- [X] [https://github.com/getsentry/sentry-python/issues/6059](\u003chttps://github.com/getsentry/sentry-python/issues/6059>)\n- [X] [https://github.com/getsentry/sentry-python/issues/6060](\u003chttps://github.com/getsentry/sentry-python/issues/6060>)\n- [X] [https://github.com/getsentry/sentry-python/issues/6066](\u003chttps://github.com/getsentry/sentry-python/issues/6066>)\n- [X] [https://github.com/getsentry/sentry-python/issues/6065](\u003chttps://github.com/getsentry/sentry-python/issues/6065>)\n\n### The rest\n\n- [X] [https://github.com/getsentry/sentry-python/issues/5996](\u003chttps://github.com/getsentry/sentry-python/issues/5996>)\n- [x] [https://github.com/getsentry/sentry-python/issues/5997](\u003chttps://github.com/getsentry/sentry-python/issues/5997>)\n- [x] [https://github.com/getsentry/sentry-python/issues/5999](\u003chttps://github.com/getsentry/sentry-python/issues/5999>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6000](\u003chttps://github.com/getsentry/sentry-python/issues/6000>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6002](\u003chttps://github.com/getsentry/sentry-python/issues/6002>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6003](\u003chttps://github.com/getsentry/sentry-python/issues/6003>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6005](\u003chttps://github.com/getsentry/sentry-python/issues/6005>)\n- [X] [https://github.com/getsentry/sentry-python/issues/6006](\u003chttps://github.com/getsentry/sentry-python/issues/6006>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6007](\u003chttps://github.com/getsentry/sentry-python/issues/6007>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6008](\u003chttps://github.com/getsentry/sentry-python/issues/6008>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6010](\u003chttps://github.com/getsentry/sentry-python/issues/6010>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6011](\u003chttps://github.com/getsentry/sentry-python/issues/6011>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6012](\u003chttps://github.com/getsentry/sentry-python/issues/6012>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6013](\u003chttps://github.com/getsentry/sentry-python/issues/6013>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6015](\u003chttps://github.com/getsentry/sentry-python/issues/6015>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6016](\u003chttps://github.com/getsentry/sentry-python/issues/6016>)\n- [X] [https://github.com/getsentry/sentry-python/issues/6017](\u003chttps://github.com/getsentry/sentry-python/issues/6017>)\n- [X] [https://github.com/getsentry/sentry-python/issues/6018](\u003chttps://github.com/getsentry/sentry-python/issues/6018>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6019](\u003chttps://github.com/getsentry/sentry-python/issues/6019>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6021](\u003chttps://github.com/getsentry/sentry-python/issues/6021>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6022](\u003chttps://github.com/getsentry/sentry-python/issues/6022>)\n- [X] [https://github.com/getsentry/sentry-python/issues/6023](\u003chttps://github.com/getsentry/sentry-python/issues/6023>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6024](\u003chttps://github.com/getsentry/sentry-python/issues/6024>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6025](\u003chttps://github.com/getsentry/sentry-python/issues/6025>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6026](\u003chttps://github.com/getsentry/sentry-python/issues/6026>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6027](\u003chttps://github.com/getsentry/sentry-python/issues/6027>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6029](\u003chttps://github.com/getsentry/sentry-python/issues/6029>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6031](\u003chttps://github.com/getsentry/sentry-python/issues/6031>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6032](\u003chttps://github.com/getsentry/sentry-python/issues/6032>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6033](\u003chttps://github.com/getsentry/sentry-python/issues/6033>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6034](\u003chttps://github.com/getsentry/sentry-python/issues/6034>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6035](\u003chttps://github.com/getsentry/sentry-python/issues/6035>)\n- [X] [https://github.com/getsentry/sentry-python/issues/6037](\u003chttps://github.com/getsentry/sentry-python/issues/6037>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6040](\u003chttps://github.com/getsentry/sentry-python/issues/6040>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6041](\u003chttps://github.com/getsentry/sentry-python/issues/6041>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6042](\u003chttps://github.com/getsentry/sentry-python/issues/6042>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6043](\u003chttps://github.com/getsentry/sentry-python/issues/6043>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6044](\u003chttps://github.com/getsentry/sentry-python/issues/6044>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6045](\u003chttps://github.com/getsentry/sentry-python/issues/6045>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6046](\u003chttps://github.com/getsentry/sentry-python/issues/6046>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6047](\u003chttps://github.com/getsentry/sentry-python/issues/6047>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6048](\u003chttps://github.com/getsentry/sentry-python/issues/6048>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6049](\u003chttps://github.com/getsentry/sentry-python/issues/6049>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6050](\u003chttps://github.com/getsentry/sentry-python/issues/6050>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6051](\u003chttps://github.com/getsentry/sentry-python/issues/6051>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6053](\u003chttps://github.com/getsentry/sentry-python/issues/6053>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6054](\u003chttps://github.com/getsentry/sentry-python/issues/6054>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6055](\u003chttps://github.com/getsentry/sentry-python/issues/6055>)\n- [X] [https://github.com/getsentry/sentry-python/issues/6056](\u003chttps://github.com/getsentry/sentry-python/issues/6056>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6057](\u003chttps://github.com/getsentry/sentry-python/issues/6057>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6058](\u003chttps://github.com/getsentry/sentry-python/issues/6058>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6061](\u003chttps://github.com/getsentry/sentry-python/issues/6061>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6062](\u003chttps://github.com/getsentry/sentry-python/issues/6062>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6063](\u003chttps://github.com/getsentry/sentry-python/issues/6063>)\n- [X] [https://github.com/getsentry/sentry-python/issues/6064](\u003chttps://github.com/getsentry/sentry-python/issues/6064>)\n- [x] [https://github.com/getsentry/sentry-python/issues/6067](\u003chttps://github.com/getsentry/sentry-python/issues/6067>)\n- [X] [https://github.com/getsentry/sentry-python/issues/6068](\u003chttps://github.com/getsentry/sentry-python/issues/6068>)\n- [X] [https://github.com/getsentry/sentry-python/issues/6069](\u003chttps://github.com/getsentry/sentry-python/issues/6069>)\n- [X] [https://github.com/getsentry/sentry-python/issues/6070](\u003chttps://github.com/getsentry/sentry-python/issues/6070>)\n- [X] [https://github.com/getsentry/sentry-python/issues/6071](\u003chttps://github.com/getsentry/sentry-python/issues/6071>)\n- [X] [https://github.com/getsentry/sentry-python/issues/6072](\u003chttps://github.com/getsentry/sentry-python/issues/6072>)","author":{"url":"https://github.com/sentrivana","@type":"Person","name":"sentrivana"},"datePublished":"2026-01-29T10:02:29Z","url":"https://github.com/getsentry/sentry-python/issues/5386"}
| 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:8101e260-bd2f-beae-65e3-a9db180bba78 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BB26:249135:574E08:74B6A8:6B00A79A |
| html-safe-nonce | b8d5e611a5fccf65ec90b885c806b4717250bedf9d664283368becdc49de0ad7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQjI2OjI0OTEzNTo1NzRFMDg6NzRCNkE4OjZCMDBBNzlBIiwidmlzaXRvcl9pZCI6IjY0NDU0MzU0ODg1MDQ0MjQzNDYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | ee845ed2d06906e68591506ced85b7d4dc6ffbbaee9e38ed63a74e7bfb762493 |
| hovercard-subject-tag | issue:3869822962 |
| 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/5386/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b0049ccc02bd645aca3681933658cfb904b22544665195489926c743cee7bfd6/getsentry/sentry-python/issues/5386 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b0049ccc02bd645aca3681933658cfb904b22544665195489926c743cee7bfd6/getsentry/sentry-python/issues/5386 |
| og:image:alt | As long as an integration interacts with tracing in some way (either creates spans on its own, or enriches existing spans with data), it needs to be migrated. If an integration doesn't do anything ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sentrivana |
| hostname | github.com |
| expected-hostname | github.com |
| None | 455b493e3402a3a3a06beac5d20bb7db3da060808b220aa48d6a7eca7c59863a |
| 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 | 2f575159976167242d488c0b062eb355c4e198b7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width