Skip to content

feat(core)!: Enable span streaming by default - #22642

Merged
Lms24 merged 1 commit into
test/opt-out-span-streaming-remainingfrom
feat/span-streaming-default
Jul 28, 2026
Merged

feat(core)!: Enable span streaming by default#22642
Lms24 merged 1 commit into
test/opt-out-span-streaming-remainingfrom
feat/span-streaming-default

Conversation

@Lms24

@Lms24 Lms24 commented Jul 24, 2026

Copy link
Copy Markdown
Member

This PR makes 'stream' the default trace lifecycle, meaning span streaming is enabled by default.

Changes:

  • traceLifecycle now has stream as a default value
  • spanStreamingIntegration is now added everywhere if traceLifecycle === 'stream'.
  • removed beforeSetup hook spanStreamingIntegration in browser SDK, since it doesn't need to set the traceLifecycle option anymore
  • added support for the SENTRY_TRACE_LIFECYCLE env vars to Node and Cloudflare to support opt-out for init-less SDK setups (AWS Lambda via the -i @sentry/aws-serverless/auto setup, Astro 3-5 Cloudflare pages)

Fixes #22344

Comment thread packages/core/src/client.ts
Comment thread packages/browser/src/sdk.ts
Comment thread packages/browser/src/sdk.ts
@github-actions

github-actions Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 29.85 kB added added
@sentry/browser - with treeshaking flags 28.06 kB added added
@sentry/browser (incl. Tracing) 47.4 kB added added
@sentry/browser (incl. Tracing + Span Streaming) 47.41 kB added added
@sentry/browser (incl. Tracing, Profiling) 52.17 kB added added
@sentry/browser (incl. Tracing, Replay) 86.73 kB added added
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 76.13 kB added added
@sentry/browser (incl. Tracing, Replay with Canvas) 91.46 kB added added
@sentry/browser (incl. Tracing, Replay, Feedback) 104.08 kB added added
@sentry/browser (incl. Feedback) 47.17 kB added added
@sentry/browser (incl. sendFeedback) 34.69 kB added added
@sentry/browser (incl. FeedbackAsync) 39.78 kB added added
@sentry/browser (incl. Metrics) 30.92 kB added added
@sentry/browser (incl. Logs) 31.15 kB added added
@sentry/browser (incl. Metrics & Logs) 31.83 kB added added
@sentry/react 31.64 kB added added
@sentry/react (incl. Tracing) 49.63 kB added added
@sentry/vue 34.77 kB added added
@sentry/vue (incl. Tracing) 49.38 kB added added
@sentry/svelte 29.88 kB added added
CDN Bundle 31.89 kB added added
CDN Bundle (incl. Tracing) 47.75 kB added added
CDN Bundle (incl. Logs, Metrics) 33.44 kB added added
CDN Bundle (incl. Tracing, Logs, Metrics) 49.14 kB added added
CDN Bundle (incl. Replay, Logs, Metrics) 72.8 kB added added
CDN Bundle (incl. Tracing, Replay) 85.36 kB added added
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 86.67 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) 91.13 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.44 kB added added
CDN Bundle - uncompressed 95.14 kB added added
CDN Bundle (incl. Tracing) - uncompressed 143.29 kB added added
CDN Bundle (incl. Logs, Metrics) - uncompressed 99.85 kB added added
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 147.27 kB added added
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 224.61 kB added added
CDN Bundle (incl. Tracing, Replay) - uncompressed 262.55 kB added added
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 266.51 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 276.25 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 280.21 kB added added
@sentry/nextjs (client) 52.2 kB added added
@sentry/sveltekit (client) 47.83 kB added added
@sentry/core/server 79.6 kB added added
@sentry/core/browser 51.55 kB added added
@sentry/node 112.54 kB added added
@sentry/node (incl. diagnostics channel injection) 156.7 kB added added
@sentry/node/import (ESM hook with diagnostics-channel injection) 166 B added added
@sentry/node - without tracing 62.07 kB added added
@sentry/aws-serverless 72.36 kB added added
@sentry/cloudflare (withSentry) - minified 196.17 kB added added
@sentry/cloudflare (withSentry) 482.89 kB added added

@Lms24
Lms24 force-pushed the feat/span-streaming-default branch from 2eeaff8 to bf07f9b Compare July 27, 2026 08:41
@Lms24
Lms24 changed the base branch from feat/span-streaming-test-opt-outs to develop July 27, 2026 08:44

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit bcca947. Configure here.

Comment thread packages/browser/src/integrations/spanstreaming.ts

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to migrate this test to span streaming since it specifically tests the Sentry.init-less loader setup. In this case, the default will be span streaming. The only way to opt-out of it would be to call Sentry.init in onload. Doing this in this test would defeat the purpose of the noOnload test scenario 😅

@Lms24 Lms24 self-assigned this Jul 27, 2026
"SENTRY_ENVIRONMENT": "qa",
"SENTRY_TRACES_SAMPLE_RATE": "1.0",
"SENTRY_TUNNEL": "http://localhost:3031/",
"SENTRY_TRACE_LIFECYCLE": "static",

@Lms24 Lms24 Jul 27, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SDK for Astro 3-5 on cloudflare can only be configured via env variables (known issue, see docs). This makes opt-out less intuitive (but still possible). Astro 6 again pulls in the correct sentry.server.config.js file which lets users opt out via Sentry.init as usual.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AWS Lambda layer is another case where the opt-out must happen via env variables, as long as users use the auto init. I think this is a fair tradeoff.

Default clients to the streamed trace lifecycle and automatically install
the required streaming integration in browser and server runtimes.
Explicit static lifecycle configuration remains supported.

Changes:
- `traceLifecycle` now defaults to `'stream'`
- `spanStreamingIntegration` is now added everywhere unless `traceLifecycle === 'static'`
  - This adds a bundle size increase to the browser SDK (~2KB gzip), unavoidable as long as
    transactions are still supported as an opt-out.
- removed the `beforeSetup` hook on `spanStreamingIntegration` in the browser SDK, since it
  no longer needs to set the `traceLifecycle` option itself
- added support for the `SENTRY_TRACE_LIFECYCLE` env var to Node, Cloudflare, and Vercel Edge
  to support opt-out for init-less SDK setups (AWS Lambda via `-i @sentry/aws-serverless/auto`,
  Astro Cloudflare pages)

BREAKING CHANGE: Spans use the streamed trace lifecycle unless configured otherwise.
Fixes #22344

Co-Authored-By: Cursor <cursoragent@cursor.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@Lms24
Lms24 force-pushed the feat/span-streaming-default branch from 031faa7 to 9788d8a Compare July 27, 2026 14:58
@Lms24
Lms24 changed the base branch from develop to test/opt-out-span-streaming-remaining July 27, 2026 14:58
dsn: 'https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737',

tracesSampleRate: 1,
traceLifecycle: 'static',

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

decided to keep bundler plugins' trace lifecycle static as well. We can opt into streaming in a separate PR. This is an interesting case because traces in the plugin have higher chance of actually getting streamed due to the longer execution time.

@Lms24
Lms24 marked this pull request as ready for review July 27, 2026 15:19
@Lms24
Lms24 requested review from a team as code owners July 27, 2026 15:19
@Lms24
Lms24 requested review from JPeer264, isaacs, logaretm and msonnb and removed request for a team July 27, 2026 15:19
@Lms24
Lms24 merged commit 36ad83e into develop Jul 28, 2026
278 of 305 checks passed
@Lms24
Lms24 deleted the feat/span-streaming-default branch July 28, 2026 07:36
Lms24 added a commit that referenced this pull request Jul 28, 2026
Explicitly sets `'static'` trace lifecycle in more tests as prework for
#22642. Mostly Deno and Bun tests this time
but also some leftover unit tests.

ref #22344

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable Span Streaming by default in v11

2 participants