Skip to content

feat(browser): Defer fetch span end until stream body resolves#20778

Draft
nicohrubec wants to merge 3 commits intodevelopfrom
feat/migrate-fetch-timestamp-adjustment-to-process-span
Draft

feat(browser): Defer fetch span end until stream body resolves#20778
nicohrubec wants to merge 3 commits intodevelopfrom
feat/migrate-fetch-timestamp-adjustment-to-process-span

Conversation

@nicohrubec
Copy link
Copy Markdown
Member

@nicohrubec nicohrubec commented May 9, 2026

Previously, when trackFetchStreamPerformance was enabled, the SDK ended http.client spans immediately when response headers arrived, then retroactively patched the end timestamp via an event processor when the transaction flushed. Now, instead of patching after the fact, the span end is deferred entirely until the response body stream resolves. The span naturally gets the correct end timestamp, which removes the need for the event processor and works for both transaction and span streaming paths.

Closes #20376

nicohrubec and others added 2 commits May 9, 2026 10:25
Add a `processSpan` hook alongside the existing event processor to
support the span streaming path for fetch stream timestamp corrections.

Ref: #20376

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Instead of ending the span at header arrival and patching timestamps
later via event processor, defer the span end until the response body
fully resolves. Removes the event processor entirely.

Closes #20376

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@nicohrubec nicohrubec changed the title feat(browser): Add processSpan hook for fetch timestamp adjustment feat(browser): Migrate fetch stream timestamp adjustment away from event processor May 9, 2026
@nicohrubec nicohrubec changed the title feat(browser): Migrate fetch stream timestamp adjustment away from event processor feat(browser): Defer fetch span end until stream body resolves May 9, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

size-limit report 📦

Path Size % Change Change
@sentry/browser 26.3 kB - -
@sentry/browser - with treeshaking flags 24.78 kB - -
@sentry/browser (incl. Tracing) 44.18 kB +0.04% +14 B 🔺
@sentry/browser (incl. Tracing + Span Streaming) 46.4 kB +0.03% +13 B 🔺
@sentry/browser (incl. Tracing, Profiling) 49.15 kB +0.03% +10 B 🔺
@sentry/browser (incl. Tracing, Replay) 83.84 kB +0.03% +17 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 73.3 kB +0.03% +18 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 88.53 kB +0.02% +16 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 101.14 kB +0.02% +14 B 🔺
@sentry/browser (incl. Feedback) 43.44 kB - -
@sentry/browser (incl. sendFeedback) 31.11 kB - -
@sentry/browser (incl. FeedbackAsync) 36.19 kB - -
@sentry/browser (incl. Metrics) 27.6 kB - -
@sentry/browser (incl. Logs) 27.73 kB - -
@sentry/browser (incl. Metrics & Logs) 28.43 kB - -
@sentry/react 28.04 kB - -
@sentry/react (incl. Tracing) 46.41 kB +0.03% +11 B 🔺
@sentry/vue 31.18 kB - -
@sentry/vue (incl. Tracing) 46.03 kB +0.03% +10 B 🔺
@sentry/svelte 26.32 kB - -
CDN Bundle 28.91 kB - -
CDN Bundle (incl. Tracing) 46.9 kB -0.09% -39 B 🔽
CDN Bundle (incl. Logs, Metrics) 30.34 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 47.97 kB -0.14% -64 B 🔽
CDN Bundle (incl. Replay, Logs, Metrics) 69.64 kB - -
CDN Bundle (incl. Tracing, Replay) 84.38 kB +0.08% +62 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 85.44 kB +0.05% +42 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 90.18 kB +0.06% +49 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 91.25 kB +0.07% +60 B 🔺
CDN Bundle - uncompressed 84.88 kB - -
CDN Bundle (incl. Tracing) - uncompressed 140.52 kB +0.06% +81 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 89.08 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 143.98 kB +0.06% +81 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 213.9 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 259.23 kB +0.04% +81 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 262.67 kB +0.04% +81 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 272.92 kB +0.03% +81 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 276.36 kB +0.03% +81 B 🔺
@sentry/nextjs (client) 48.92 kB +0.04% +16 B 🔺
@sentry/sveltekit (client) 44.65 kB +0.03% +12 B 🔺
@sentry/node-core 60.48 kB +0.02% +7 B 🔺
@sentry/node 165.51 kB +0.01% +9 B 🔺
@sentry/node - without tracing 73.49 kB +0.01% +6 B 🔺
@sentry/aws-serverless 107.64 kB +0.01% +6 B 🔺
@sentry/cloudflare (withSentry) - minified 169.35 kB - -
@sentry/cloudflare (withSentry) 427.5 kB - -

View base workflow run

Instead of reimplementing endSpan logic (HTTP status, content-length,
onRequestSpanEnd), stash the original handlerData, put the span back
in the spans record, and let instrumentFetchRequest handle everything.

Co-Authored-By: Claude Opus 4.6 (1M context) <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.

Event processor migration: Browser fetch timestamp adjustments (TBD)

1 participant