Skip to content

Investigate tree shaking of transaction code when span streaming is used #22580

Open

Description

@Lms24

Span streaming adds a hefty bundle size increase (~5KB gzip, 2-3KB added via the spanStreamingIntegration, rest is in core code) to the SDK, when enabled. In v11, streaming becomes the default, so the size increase is always there. We should investigate if we can provide a tree shaking flag for bundle-size conscious users that takes care of removing transaction code paths that are "dead code" for streaming mode.

This is also a good exercise for us to determine which code paths we should remove once transactions are no longer supported by the SDK (v12?). Plus it will give us a projection of the since decrease this will yield.

Activity

  1. linear-code commented on Jul 24, 2026

    @linear-code
  2. changed the title [-]Investigate adding a tree shaking flag to remove transaction code when span streaming is used[/-] [+]Investigate adding tree shaking of transaction code when span streaming is used[/+] on Jul 24, 2026
  3. changed the title [-]Investigate adding tree shaking of transaction code when span streaming is used[/-] [+]Investigate tree shaking of transaction code when span streaming is used[/+] on Jul 24, 2026
  4. sentry-junior commented on Nov 5, 2026

    @sentry-junior
    Contributor

    I opened #26144 for this. It adds an opt-in __SENTRY_EXCLUDE_TRANSACTIONS__ build flag. When you replace it with true, the SDK always streams spans (traceLifecycle: 'static' is ignored) and the transaction code paths become dead code. Defaults don't change.

    I measured it with esbuild 0.27 (minify, ESM, browser, __SENTRY_DEBUG__: false) on a tracing-only setup: BrowserClient + browserTracingIntegration, tracesSampleRate: 1.

    raw gzip brotli-11
    develop 131,185 45,437 40,286
    flag true 127,648 (−3,537) 44,358 (−1,079) 39,362 (−924)
    flag unset (guard overhead) +606 +76 +45

    With webpack through size-limit (init + browserTracingIntegration), the flag saves 1,405 B gzip.

    The PR also lists the transaction-only paths it leaves in. Those are a starting list for what to remove once transactions go away entirely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions