Skip to content

fix(browser): Apply Http timing attributes to streamed http.client spans#19643

Merged
Lms24 merged 8 commits intolms/feat-span-firstfrom
lms/fix-http-client-request-timing-attributes
Mar 9, 2026
Merged

fix(browser): Apply Http timing attributes to streamed http.client spans#19643
Lms24 merged 8 commits intolms/feat-span-firstfrom
lms/fix-http-client-request-timing-attributes

Conversation

@Lms24
Copy link
Member

@Lms24 Lms24 commented Mar 5, 2026

This PR fixes a temporary bug in span streaming where we didn't add Http timing attributes (see #19613). We can fix this by following OTels approach:

  • delay the ending of http.client spans until either 300ms pass by or we receive the PerformanceResourceTiming entry with the respective timing information. Of course we end the span with the original timestamp then.
  • Unfortunately, we can only do this for streamed span because transaction-based spans cannot stay open longer than their parent (e.g. a pageload or navigation). Otherwise they'd get dropped. So we have to differentiate between the two modes here (RIP bundle size 😢)
  • To ensure we don't flush unnecessarily often, we also now delay flushing the span buffer for 500ms after a segment span ends. This slightly changed test semantics in a few integration tests because manually consecutively segments are now also sent in one envelope. This is completely fine (actually preferred) because we flush less often (i.e. fewer requests).

closes #19613

@Lms24 Lms24 changed the base branch from develop to lms/feat-span-first March 5, 2026 09:59
@Lms24 Lms24 changed the base branch from lms/feat-span-first to lms/test-span-streaming-browser-integration-tests March 5, 2026 10:00
@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

size-limit report 📦

Path Size % Change Change
@sentry/browser 25.71 kB added added
@sentry/browser - with treeshaking flags 24.21 kB added added
@sentry/browser (incl. Tracing) 42.8 kB added added
@sentry/browser (incl. Tracing, Profiling) 47.48 kB added added
@sentry/browser (incl. Tracing, Replay) 81.63 kB added added
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 71.23 kB added added
@sentry/browser (incl. Tracing, Replay with Canvas) 86.3 kB added added
@sentry/browser (incl. Tracing, Replay, Feedback) 98.57 kB added added
@sentry/browser (incl. Feedback) 42.51 kB added added
@sentry/browser (incl. sendFeedback) 30.38 kB added added
@sentry/browser (incl. FeedbackAsync) 35.43 kB added added
@sentry/browser (incl. Metrics) 26.87 kB added added
@sentry/browser (incl. Logs) 27.02 kB added added
@sentry/browser (incl. Metrics & Logs) 27.69 kB added added
@sentry/react 27.47 kB added added
@sentry/react (incl. Tracing) 45.15 kB added added
@sentry/vue 30.37 kB added added
@sentry/vue (incl. Tracing) 44.68 kB added added
@sentry/svelte 25.74 kB added added
CDN Bundle 28.24 kB added added
CDN Bundle (incl. Tracing) 43.63 kB added added
CDN Bundle (incl. Logs, Metrics) 29.07 kB added added
CDN Bundle (incl. Tracing, Logs, Metrics) 44.48 kB added added
CDN Bundle (incl. Replay, Logs, Metrics) 68.17 kB added added
CDN Bundle (incl. Tracing, Replay) 80.46 kB added added
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 81.37 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) 86 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 86.9 kB added added
CDN Bundle - uncompressed 82.55 kB added added
CDN Bundle (incl. Tracing) - uncompressed 129.13 kB added added
CDN Bundle (incl. Logs, Metrics) - uncompressed 85.38 kB added added
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 131.96 kB added added
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 209.05 kB added added
CDN Bundle (incl. Tracing, Replay) - uncompressed 246.01 kB added added
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 248.83 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 258.92 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 261.73 kB added added
@sentry/nextjs (client) 47.56 kB added added
@sentry/sveltekit (client) 43.27 kB added added
@sentry/node-core 52.32 kB added added
@sentry/node 174.99 kB added added
@sentry/node - without tracing 97.47 kB added added
@sentry/aws-serverless 113.27 kB added added

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

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 9,254 - - added
GET With Sentry 1,732 19% - added
GET With Sentry (error only) 6,092 66% - added
POST Baseline 1,204 - - added
POST With Sentry 591 49% - added
POST With Sentry (error only) 1,033 86% - added
MYSQL Baseline 3,238 - - added
MYSQL With Sentry 470 15% - added
MYSQL With Sentry (error only) 2,637 81% - added

@Lms24 Lms24 force-pushed the lms/test-span-streaming-browser-integration-tests branch from c28083a to 06bccc6 Compare March 6, 2026 10:19
Base automatically changed from lms/test-span-streaming-browser-integration-tests to lms/feat-span-first March 6, 2026 12:33
@Lms24 Lms24 force-pushed the lms/fix-http-client-request-timing-attributes branch from bfee1f9 to 6b0eb4f Compare March 6, 2026 13:10
@Lms24 Lms24 marked this pull request as ready for review March 6, 2026 13:16
@Lms24 Lms24 requested review from JPeer264, andreiborza and s1gr1d March 6, 2026 13:16
client.on('afterSegmentSpanEnd', segmentSpan => buffer.flush(segmentSpan.spanContext().traceId));
client.on('afterSegmentSpanEnd', segmentSpan => {
const traceId = segmentSpan.spanContext().traceId;
setTimeout(() => {
Copy link
Member

Choose a reason for hiding this comment

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

q/l: Should we wrap this in our safeUnref function? Or is this guaranteed to run only on the browser?

Copy link
Member Author

Choose a reason for hiding this comment

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

it's guaranteed to only run in the browser. There will be a dedicated server-side spanStreamingIntegration which doesn't need this logic

Copy link

@cursor cursor bot left a comment

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.

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

gzip: false,
brotli: false,
limit: '129 KB',
limit: '130 KB',
Copy link

Choose a reason for hiding this comment

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

Browser bundle size increase flagged per project rules

Low Severity

The CDN Bundle (incl. Tracing) uncompressed size limit increased from 129 KB to 130 KB (~0.8% increase). Per the project rules, large bundle size increases in browser packages need to be flagged even when unavoidable. The PR description acknowledges this trade-off for adding HTTP timing support to streamed spans.

Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

@Lms24 Lms24 merged commit 05f5294 into lms/feat-span-first Mar 9, 2026
220 of 224 checks passed
@Lms24 Lms24 deleted the lms/fix-http-client-request-timing-attributes branch March 9, 2026 13:26
Lms24 added a commit that referenced this pull request Mar 9, 2026
…spans (#19643)

This PR fixes a temporary bug in span streaming where we didn't add Http
timing attributes (see
#19613). We can fix
this by following OTels approach:

- delay the ending of `http.client` spans until either 300ms pass by or
we receive the PerformanceResourceTiming entry with the respective
timing information. Of course we end the span with the original
timestamp then.
- Unfortunately, we can only do this for streamed span because
transaction-based spans cannot stay open longer than their parent (e.g.
a pageload or navigation). Otherwise they'd get dropped. So we have to
differentiate between the two modes here (RIP bundle size 😢)
- To ensure we don't flush unnecessarily often, we also now delay
flushing the span buffer for 500ms after a segment span ends. This
slightly changed test semantics in a few integration tests because
manually consecutively segments are now also sent in one envelope. This
is completely fine (actually preferred) because we flush less often
(i.e. fewer requests).

closes #19613
Lms24 added a commit that referenced this pull request Mar 10, 2026
…spans (#19643)

This PR fixes a temporary bug in span streaming where we didn't add Http
timing attributes (see
#19613). We can fix
this by following OTels approach:

- delay the ending of `http.client` spans until either 300ms pass by or
we receive the PerformanceResourceTiming entry with the respective
timing information. Of course we end the span with the original
timestamp then.
- Unfortunately, we can only do this for streamed span because
transaction-based spans cannot stay open longer than their parent (e.g.
a pageload or navigation). Otherwise they'd get dropped. So we have to
differentiate between the two modes here (RIP bundle size 😢)
- To ensure we don't flush unnecessarily often, we also now delay
flushing the span buffer for 500ms after a segment span ends. This
slightly changed test semantics in a few integration tests because
manually consecutively segments are now also sent in one envelope. This
is completely fine (actually preferred) because we flush less often
(i.e. fewer requests).

closes #19613
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