Title: Consolidate propagation and dynamic sampling contexts on Scope · Issue #10095 · getsentry/sentry-javascript · GitHub
Open Graph Title: Consolidate propagation and dynamic sampling contexts on Scope · Issue #10095 · getsentry/sentry-javascript
X Title: Consolidate propagation and dynamic sampling contexts on Scope · Issue #10095 · getsentry/sentry-javascript
Description: Problem Statement Right now, we already have PropagationAPIs on the Scope ((get|set)PropagationContext). The propagation context also holds a dynamic sampling context. However, we also have/had (#10094) APIs like transaction.getDynamicSa...
Open Graph Description: Problem Statement Right now, we already have PropagationAPIs on the Scope ((get|set)PropagationContext). The propagation context also holds a dynamic sampling context. However, we also have/had (#1...
X Description: Problem Statement Right now, we already have PropagationAPIs on the Scope ((get|set)PropagationContext). The propagation context also holds a dynamic sampling context. However, we also have/had (#1...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/10095
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Consolidate propagation and dynamic sampling contexts on Scope","articleBody":"### Problem Statement\r\n\r\nRight now, we already have `PropagationAPIs` on the Scope (`(get|set)PropagationContext`). The propagation context also holds a dynamic sampling context. However, we also have/had (#10094) APIs like `transaction.getDynamicSamplingContext` which in many situations returned different DSC data than propagation context.\r\n\r\nThis leads to the inconvenience that everywhere where we need to propagate tracing data, we kinda have to check if there's an active txn, if yes, get the DSC from there and only otherwise use the DSC from the propagation context.\r\n\r\n### Solution Brainstorm\r\n\r\nAn ideal solution IMO is to always view `Scope.getPropagationContext` as the source of truth for trace propagation.\r\n\r\n- Calling `getIsolationScope().getPropagationContext` always returns the correct distributed tracing data (that is, traceparent data and DSC). Regardless of if there is an active span or not (TwP).\r\n- There should be no need to call any additional function or method when propagating tracing information\r\n- Ensuring DSC is immutable for transactions should still work, although it’s not enforced at the moment\r\n - In this case, the first `getPropagationContext` call would “freeze” the DSC for the current active transaction/root span\r\n\r\nAlso, this is how propagation context should work according to our [distributed tracing dev spec](https://develop.sentry.dev/sdk/distributed-tracing/).\r\n\r\n### `getPropagationContext` Cases (with immutability)\r\n\r\n- No active span\r\n - return fallback DSC (i.e. the one created initially TwP OR the one that was added via `setPropagationContext`\r\n- Active span\r\n - There already is DSC for this span\r\n - Return this one in the PC\r\n - No propagationContext for this span (or we don’t care about immutability)\r\n - populate new one in the PC \r\n\r\n### Note: Current State of mutability of DSC\r\n\r\n- If DSC is set on the transaction when it’s created (e.g. via startTxn or startSpan), this DSC [will be returned](https://github.com/getsentry/sentry-javascript/blob/5eeb8a9ef25cf1809a149a6b0b00e823f9f96536/packages/core/src/tracing/transaction.ts/#L72-L78) from calling `getDynamicSamplingContext`\r\n- Otherwise, calling `getDynamicSamplingContext` [will always return a fresh DSC](https://github.com/getsentry/sentry-javascript/blob/5eeb8a9ef25cf1809a149a6b0b00e823f9f96536/packages/core/src/tracing/transaction.ts/#L220-L222) and ignore previously calculated DSC.\r\n - This differs from the DSC spec that postulates that once populated for a trace, the DSC must not be mutated.\r\n - We did this on purpose for a experiment and never revisited the logic, hence it’s still active\r\n - Talked with Jan: Let’s leave it as is for now, document it well, but once things stabilize with new APIs and the major is out, we should reevaluate if the current data works for our server-side DS logic or if we should re-introduce immutability.","author":{"url":"https://github.com/Lms24","@type":"Person","name":"Lms24"},"datePublished":"2024-01-08T12:39:04Z","url":"https://github.com/getsentry/sentry-javascript/issues/10095"}
| 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:53f10fd8-eb3a-f0dc-fb1f-093a1da9fe6b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AC7E:14278D:2285D4:2F2567:6B044C3E |
| html-safe-nonce | 8d82169e0ea498186c0999778ad7879703d14d2cb8498b3a2bdba7d3bd5ab94d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQzdFOjE0Mjc4RDoyMjg1RDQ6MkYyNTY3OjZCMDQ0QzNFIiwidmlzaXRvcl9pZCI6IjYwODM4NjgyOTY2NjU2NDgxOTAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 16ad280bc2721c3b8dcf6cbff8c1cbbacad215914e563a44f79ec64a056187d1 |
| hovercard-subject-tag | issue:2070375849 |
| 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-javascript/10095/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fc0a517a51913a3954e8a4cb3a8f937039df9fccc01bf885fac7fc1914fb490e/getsentry/sentry-javascript/issues/10095 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fc0a517a51913a3954e8a4cb3a8f937039df9fccc01bf885fac7fc1914fb490e/getsentry/sentry-javascript/issues/10095 |
| og:image:alt | Problem Statement Right now, we already have PropagationAPIs on the Scope ((get|set)PropagationContext). The propagation context also holds a dynamic sampling context. However, we also have/had (#1... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Lms24 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 002aa6b95ffa730b0aec436a5c383f536ad677284e60056037fb120afe37b730 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| 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 | 059f24c781e3a0d7df3f27a97da0e93fab06ae39 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width