Skip to content

Conversation

@Lms24
Copy link
Member

@Lms24 Lms24 commented Oct 2, 2025

This PR contains the POC span streaming implementation for browser SDKs.

Can be tested on @sentry/browser@10.21.0-alpha.1 and any higher-level SDKs.

To opt into span streaming, set:

Sentry.init({
  dsn: '...',
  tracesSampleRate: 1,
  traceLifecycle: 'stream', <-- 
  integrations: [
    Sentry.browserTracingIntegration();
    Sentry.spanStreamingIntegration(); <-- 
  ],

  // if you use beforeSendSpan, you have to opt into the new serialized span format:
  beforeSendSpan: withStreamSpan(serializedSpan => {
     // do something
     return serializedSpan
   }),
})

Also note that spans will no longer be sent to any event processors added via one if the *.addEventProcessor APIs. If you have any event processors, consider using beforeSendSpan or ignoreSpans.

@Lms24 Lms24 changed the title feat: Span Streaming POC [WIP] feat: Span Streaming POC Oct 2, 2025
@Lms24 Lms24 self-assigned this Oct 2, 2025
@Lms24 Lms24 force-pushed the lms/feat-span-streaming-poc branch from 31db546 to 20590fe Compare October 2, 2025 14:59
@github-actions
Copy link
Contributor

github-actions bot commented Oct 2, 2025

size-limit report 📦

Path Size % Change Change
⛔️ @sentry/browser (max: 25 kB) 25.65 kB +3.42% +846 B 🔺
⛔️ @sentry/browser - with treeshaking flags (max: 24.1 kB) 24.19 kB +3.82% +888 B 🔺
⛔️ @sentry/browser (incl. Tracing) (max: 42 kB) 42.6 kB +2.55% +1.06 kB 🔺
@sentry/browser (incl. Tracing, Profiling) 47.18 kB +2.26% +1.04 kB 🔺
@sentry/browser (incl. Tracing, Replay) 81.13 kB +1.46% +1.16 kB 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 70.72 kB +1.47% +1.02 kB 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 85.8 kB +1.37% +1.15 kB 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 97.99 kB +1.15% +1.11 kB 🔺
⛔️ @sentry/browser (incl. Feedback) (max: 42 kB) 42.35 kB +2.01% +831 B 🔺
@sentry/browser (incl. sendFeedback) 30.31 kB +2.79% +821 B 🔺
⛔️ @sentry/browser (incl. FeedbackAsync) (max: 35 kB) 35.33 kB +2.45% +844 B 🔺
⛔️ @sentry/react (max: 27 kB) 27.38 kB +3.23% +856 B 🔺
@sentry/react (incl. Tracing) 44.86 kB +2.53% +1.1 kB 🔺
@sentry/vue 30.29 kB +3.49% +1.02 kB 🔺
⛔️ @sentry/vue (incl. Tracing) (max: 44 kB) 44.43 kB +2.47% +1.07 kB 🔺
⛔️ @sentry/svelte (max: 25 kB) 25.68 kB +3.45% +856 B 🔺
⛔️ CDN Bundle (max: 27.5 kB) 27.98 kB +2.73% +743 B 🔺
⛔️ CDN Bundle (incl. Tracing) (max: 43 kB) 43.22 kB +2.35% +992 B 🔺
CDN Bundle (incl. Tracing, Replay) 79.73 kB +1.25% +981 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 85.2 kB +1.18% +992 B 🔺
⛔️ CDN Bundle - uncompressed (max: 82 kB) 82.24 kB +2.75% +2.2 kB 🔺
⛔️ CDN Bundle (incl. Tracing) - uncompressed (max: 127 kB) 128.42 kB +2.42% +3.03 kB 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 244.45 kB +1.26% +3.03 kB 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 257.21 kB +1.2% +3.03 kB 🔺
⛔️ @sentry/nextjs (client) (max: 47 kB) 47.04 kB +2.34% +1.07 kB 🔺
⛔️ @sentry/sveltekit (client) (max: 43 kB) 43.02 kB +2.63% +1.1 kB 🔺
@sentry/node-core 51.83 kB +0.65% +332 B 🔺
⛔️ @sentry/node (max: 161 kB) 161.92 kB +1.32% +2.11 kB 🔺
@sentry/node - without tracing 94.93 kB +2.17% +2.01 kB 🔺
@sentry/aws-serverless 110.47 kB +1.89% +2.04 kB 🔺

View base workflow run

@github-actions
Copy link
Contributor

github-actions bot commented Oct 2, 2025

node-overhead report 🧳

Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.

Scenario Requests/s % of Baseline Prev. Requests/s Change %
GET Baseline 8,706 - 8,957 -3%
GET With Sentry 1,393 16% 1,711 -19%
GET With Sentry (error only) 6,160 71% 6,023 +2%
POST Baseline 1,154 - 1,167 -1%
POST With Sentry 517 45% 559 -8%
POST With Sentry (error only) 1,017 88% 1,035 -2%
MYSQL Baseline 3,309 - 3,296 +0%
MYSQL With Sentry 418 13% 461 -9%
MYSQL With Sentry (error only) 2,684 81% 2,589 +4%

View base workflow run

@Lms24 Lms24 force-pushed the lms/feat-span-streaming-poc branch 2 times, most recently from 84ec3fe to 4c1a555 Compare October 15, 2025 14:50
@Lms24 Lms24 force-pushed the lms/feat-span-streaming-poc branch from dc5f6de to a2aec25 Compare October 16, 2025 12:06
@Lms24 Lms24 force-pushed the lms/feat-span-streaming-poc branch from 7bb62f4 to fd533f3 Compare October 31, 2025 09:02
@Lms24 Lms24 force-pushed the lms/feat-span-streaming-poc branch 2 times, most recently from a35edc7 to 2d9b938 Compare November 12, 2025 10:58
@Lms24 Lms24 force-pushed the lms/feat-span-streaming-poc branch from e8e3944 to 2049208 Compare November 12, 2025 16:21
@Lms24 Lms24 force-pushed the lms/feat-span-streaming-poc branch from 2049208 to 860265a Compare November 19, 2025 16:43
@Lms24 Lms24 force-pushed the lms/feat-span-streaming-poc branch from 860265a to 41c93ff Compare November 21, 2025 14:34
@Lms24 Lms24 force-pushed the lms/feat-span-streaming-poc branch 2 times, most recently from 23c46cd to 25b73c6 Compare November 25, 2025 12:53
@Lms24 Lms24 force-pushed the lms/feat-span-streaming-poc branch from 66b37be to 282eed0 Compare December 11, 2025 14:34
}

expect(pageloadSpan!.attributes?.['ui.web_vital.ttfb.requestTime']).toEqual({
type: expect.stringMatching(/^integer|double$/),

Check failure

Code scanning / CodeQL

Missing regular expression anchor High test

Misleading operator precedence. The subexpression 'double$' is anchored at the end, but the other parts of this regular expression are not
Misleading operator precedence. The subexpression '^integer' is anchored at the beginning, but the other parts of this regular expression are not

Copilot Autofix

AI about 8 hours ago

To fix this problem, the regular expression should be modified to match exactly either "integer" or "double," i.e., the string should be anchored at both the start (^) and end ($). The correct regular expression is /^(integer|double)$/, which matches only the whole string "integer" or "double" and nothing else. This change should be made on line 30 of the file dev-packages/browser-integration-tests/suites/span-first/web-vitals/web-vitals-ttfb/test.ts inside the expect.stringMatching argument. No additional imports or changes are required.


Suggested changeset 1
dev-packages/browser-integration-tests/suites/span-first/web-vitals/web-vitals-ttfb/test.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/dev-packages/browser-integration-tests/suites/span-first/web-vitals/web-vitals-ttfb/test.ts b/dev-packages/browser-integration-tests/suites/span-first/web-vitals/web-vitals-ttfb/test.ts
--- a/dev-packages/browser-integration-tests/suites/span-first/web-vitals/web-vitals-ttfb/test.ts
+++ b/dev-packages/browser-integration-tests/suites/span-first/web-vitals/web-vitals-ttfb/test.ts
@@ -27,7 +27,7 @@
   }
 
   expect(pageloadSpan!.attributes?.['ui.web_vital.ttfb.requestTime']).toEqual({
-    type: expect.stringMatching(/^integer|double$/),
+    type: expect.stringMatching(/^(integer|double)$/),
     value: expect.any(Number),
   });
 });
EOF
@@ -27,7 +27,7 @@
}

expect(pageloadSpan!.attributes?.['ui.web_vital.ttfb.requestTime']).toEqual({
type: expect.stringMatching(/^integer|double$/),
type: expect.stringMatching(/^(integer|double)$/),
value: expect.any(Number),
});
});
Copilot is powered by AI and may make mistakes. Always verify output.
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.

2 participants