Skip to content

feat(browser): Add support for streamed spans in httpContextIntegration#20464

Merged
nicohrubec merged 5 commits intodevelopfrom
nh/span-streaming-httpcontextintegration
Apr 24, 2026
Merged

feat(browser): Add support for streamed spans in httpContextIntegration#20464
nicohrubec merged 5 commits intodevelopfrom
nh/span-streaming-httpcontextintegration

Conversation

@nicohrubec
Copy link
Copy Markdown
Member

This PR adds span processing support for the httpContextIntegration :

Closes #20378


const reqData = getHttpRequestData();

span.attributes = {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

l: instead of spreading this here, can we just set the attributes we want to set directly? IMHO we can just have a utility we keep using like setIfNotExists(span.attributes, 'url.full', reqData.url), or similar? Not 100% sure but I'd suspect this is faster at scale than creating a new object all the time when processing spans like this?

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.

We have a utility @sentry/core that does exactly what we would want I think (ref). We could export that from core and then use it in any integrations we need to port. I copied the approach here from how Lukas did the cultureContext integration (ref), not sure if he had a specific reason in mind not to use this. Wdyt?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

sounds good to me (exporting this and using it). FWIW the approach from lukas and in this PR are not bad I just think it is slightly better (probably) to avoid creating new objects for these things all the time - and this will likely happen quite a lot if there are multiple event processors all just adding one or two attributes!

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 23, 2026

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 25.98 kB +0.42% +107 B 🔺
@sentry/browser - with treeshaking flags 24.46 kB +0.46% +112 B 🔺
@sentry/browser (incl. Tracing) 43.91 kB +0.24% +105 B 🔺
@sentry/browser (incl. Tracing + Span Streaming) 45.54 kB +0.1% +41 B 🔺
@sentry/browser (incl. Tracing, Profiling) 48.87 kB +0.28% +132 B 🔺
@sentry/browser (incl. Tracing, Replay) 83.11 kB +0.17% +133 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 72.59 kB +0.14% +96 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 87.79 kB +0.14% +116 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 100.05 kB +0.13% +123 B 🔺
@sentry/browser (incl. Feedback) 42.78 kB +0.19% +77 B 🔺
@sentry/browser (incl. sendFeedback) 30.65 kB +0.33% +99 B 🔺
@sentry/browser (incl. FeedbackAsync) 35.64 kB +0.24% +85 B 🔺
@sentry/browser (incl. Metrics) 27.27 kB +0.4% +106 B 🔺
@sentry/browser (incl. Logs) 27.4 kB +0.41% +111 B 🔺
@sentry/browser (incl. Metrics & Logs) 28.09 kB +0.4% +110 B 🔺
@sentry/react 27.73 kB +0.39% +107 B 🔺
@sentry/react (incl. Tracing) 46.14 kB +0.21% +94 B 🔺
@sentry/vue 30.83 kB +0.39% +117 B 🔺
@sentry/vue (incl. Tracing) 45.72 kB +0.21% +95 B 🔺
@sentry/svelte 26 kB +0.41% +106 B 🔺
CDN Bundle 28.66 kB +0.3% +84 B 🔺
CDN Bundle (incl. Tracing) 46.13 kB +0.12% +55 B 🔺
CDN Bundle (incl. Logs, Metrics) 30.04 kB +0.29% +86 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) 47.17 kB +0.13% +58 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 69.02 kB +0.15% +103 B 🔺
CDN Bundle (incl. Tracing, Replay) 83.19 kB +0.07% +58 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 84.22 kB +0.07% +54 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 88.68 kB +0.09% +76 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 89.76 kB +0.08% +70 B 🔺
CDN Bundle - uncompressed 83.94 kB +0.42% +348 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 137.84 kB +0.17% +226 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 88.08 kB +0.4% +348 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 141.26 kB +0.17% +226 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 211.66 kB +0.17% +348 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 255.29 kB +0.09% +226 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 258.68 kB +0.09% +226 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 268.2 kB +0.09% +226 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 271.59 kB +0.09% +226 B 🔺
@sentry/nextjs (client) 48.66 kB +0.18% +87 B 🔺
@sentry/sveltekit (client) 44.34 kB +0.29% +124 B 🔺
@sentry/node-core 58.35 kB +0.02% +9 B 🔺
@sentry/node 175.67 kB +0.01% +13 B 🔺
@sentry/node - without tracing 98.3 kB +0.02% +11 B 🔺
@sentry/aws-serverless 115.33 kB +0.02% +12 B 🔺

View base workflow run

@nicohrubec nicohrubec marked this pull request as ready for review April 23, 2026 13:02
Comment thread packages/browser/src/integrations/httpcontext.ts
Copy link
Copy Markdown

@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.

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 7c5c438. Configure here.

Comment thread packages/browser/src/integrations/httpcontext.ts Outdated
Comment thread packages/browser/src/integrations/httpcontext.ts Outdated
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@nicohrubec nicohrubec requested review from chargome and mydea April 24, 2026 07:41
@nicohrubec nicohrubec merged commit 57c0287 into develop Apr 24, 2026
496 of 498 checks passed
@nicohrubec nicohrubec deleted the nh/span-streaming-httpcontextintegration branch April 24, 2026 08:27
nicohrubec added a commit that referenced this pull request Apr 24, 2026
…ration (#20481)

Applies the same `safeSetSpanJSONAttributes` refactor from #20464 to the
`cultureContext` integration's `processSegmentSpan` hook. This gives us
in-place mutation instead of spread-and-reassign and nullish values are
skipped (these get dropped during serialization anyways but doesn't hurt
to just not assign them in the first place).

Co-authored-by: Claude Opus 4.7 (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 httpContextIntegration

2 participants