Title: Rework `sampling_context` · Issue #3746 · getsentry/sentry-python · GitHub
Open Graph Title: Rework `sampling_context` · Issue #3746 · getsentry/sentry-python
X Title: Rework `sampling_context` · Issue #3746 · getsentry/sentry-python
Description: (custom_)sampling_context is a Sentry-specific concept that doesn't fit with how OTel works. The purpose of a sampling_context is to provide extra external data to use for decision making in the traces_sampler. Right now, we're using it ...
Open Graph Description: (custom_)sampling_context is a Sentry-specific concept that doesn't fit with how OTel works. The purpose of a sampling_context is to provide extra external data to use for decision making in the tr...
X Description: (custom_)sampling_context is a Sentry-specific concept that doesn't fit with how OTel works. The purpose of a sampling_context is to provide extra external data to use for decision making in th...
Opengraph URL: https://github.com/getsentry/sentry-python/issues/3746
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Rework `sampling_context`","articleBody":"`(custom_)sampling_context` is a Sentry-specific concept that doesn't fit with how OTel works.\n\nThe purpose of a `sampling_context` is to provide extra external data to use for decision making in the `traces_sampler`. Right now, we're using it to make things like the transaction name, parent sampled decision, request object or queue name accessible in the sampler.\n\nThe goal is to store everything necessary on the span as attributes instead and expose those. However, since attribute types are very limited, we can't just save a custom object like e.g. the request as an attribute. Instead, we need to preprocess it into serializable attributes. For each integration, we need to see what important data we can extract and save on the span.\n\nThe idea:\n- no `custom_sampling_context` argument for `start_transaction`/`start_span` anymore\n- `start_span` instead gets an extra `attributes` argument which, when provided, prepopulates the attributes\n- integrations that were providing a `custom_sampling_context` will instead provide a set of prepopulated `attributes` (that can't be objects)\n- the `sampling_context` accessible in `traces_sampler` will change:\n - it'll contain all span attributes by default\n - it'll also contain the current data (`transaction_context.name`, `transaction_context.op`, `parent_sampled`) in some slightly modified form\n\nIntegrations that are currently setting a `custom_sampling_context` that will now have to set specific attributes:\n\n- [x] aiohttp https://github.com/getsentry/sentry-python/pull/3782\n- [x] asgi https://github.com/getsentry/sentry-python/pull/3764 & https://github.com/getsentry/sentry-python/pull/3774\n- [x] aws_lambda https://github.com/getsentry/sentry-python/pull/3814\n- [x] celery https://github.com/getsentry/sentry-python/pull/3813\n- [x] gcp https://github.com/getsentry/sentry-python/pull/3818\n- [x] rq https://github.com/getsentry/sentry-python/pull/3786\n- [x] tornado https://github.com/getsentry/sentry-python/pull/3784\n- [x] wsgi https://github.com/getsentry/sentry-python/pull/3775\n- [x] extra\n - see if there's any framework-specific stuff in e.g. the asgi scope (starlette/fastapi adds `endpoint`, for instance), and add if possible\n - seen in the wild: `wsgi_environ.REQUEST_URI`, `wsgi_environ.HTTP_` headers stuff\n - consider serializing args and kwargs (mostly celery, rq) always in the same way (i.e., not via `_serialize_span_attributes`) so that the type doesn't randomly change on users\n - error handling (`except:` or `capture_internal_exceptions`)\n\n\nRelated:\n\n- [x] Allow to pass attributes to `POTelSpan` https://github.com/getsentry/sentry-python/pull/3747\n- [x] Document this properly in the migration guide for each integration\n- [ ] Change documentation https://docs.sentry.io/platforms/python/configuration/sampling/ https://github.com/getsentry/sentry-python/issues/3933","author":{"url":"https://github.com/sentrivana","@type":"Person","name":"sentrivana"},"datePublished":"2024-11-07T10:00:55Z","url":"https://github.com/getsentry/sentry-python/issues/3746"}
| 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:99e26ba7-3c57-b09e-802e-1eb19b47868a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8414:1AE20C:83075:AB76C:6B00C568 |
| html-safe-nonce | 6cd82250a3367e8ce66ef10f6267f9164ff98c4a0f13d202e80c13baafe961e7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NDE0OjFBRTIwQzo4MzA3NTpBQjc2Qzo2QjAwQzU2OCIsInZpc2l0b3JfaWQiOiI4NjY0Mjc3Njk0NTUwMTY0ODQwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | d633181022b5d7cd3177983a1d965283683372fcc9feb0d7d78a18c3fa1b4353 |
| hovercard-subject-tag | issue:2640495580 |
| 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/3746/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4042845b90197a47e228d90e264a76a90c3d5fd94ac3f8fd3ca324a9d12653ed/getsentry/sentry-python/issues/3746 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4042845b90197a47e228d90e264a76a90c3d5fd94ac3f8fd3ca324a9d12653ed/getsentry/sentry-python/issues/3746 |
| og:image:alt | (custom_)sampling_context is a Sentry-specific concept that doesn't fit with how OTel works. The purpose of a sampling_context is to provide extra external data to use for decision making in the tr... |
| 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 | 98dc00e171c204462a6f367482a0f8c3c6b5dbca99cd7390e82d2df49ce096e4 |
| 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 | ef013399cf0a3c324bea644a685d7c1e0f06b5b7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width