Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(core): Send user-agent header with envelope requests in server SDKs #17929

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Lms24 merged 8 commits into develop from lms/feat-core-send-user-agent-envelope-requests
Oct 28, 2025

Conversation

@Lms24
Copy link
Member

@Lms24 Lms24 commented Oct 14, 2025
edited
Loading

Update: Removed browser functionality (see below for reasons)

As a follow-up of an incident (quite a while ago, but this unfortunately slipped through), SDKs were asked to send a user-agent Http header to determine by just looking at incoming request headers which SDK the request is coming from. See develop specification.

This PR makes the following changes to sending user agent HTTP headers with envelope requests made by the transport:

  • Send user-agent in all server-runtime SDKs
  • Extract the headers option from individual transport options to BaseTransportOptions. This allows us to type-safely add the user agent header to the SDKs transport options which is the easiest way to pass a header to the transport without having to modify or extend any of the existing transport APIs. I checked and every transport implementation we currently export exposed a headers option anyway, so this just unifies it. Given this is an optional property, custom transport implementations extending BaseTransportOptions won't break either. The problem here is only that they might not actually support this option which all things considered I think is fine. If reviewers have different opinions, I'm happy to revisit this.
  • Unit and integration/e2e tests for node and cloudflare

This PR makes no change to the sdk envelope header which carries the same (more detailed) information (but in the request body)

Why not in Browser SDKs?

  1. Relay infers the user's browser information based on user-agent, so we cannot set a custom user agent name that overwrites it.
  2. We also cannot add a custom header (something like x-sentry-user-agent) because then the SDK would send a non-standard header which could block all requests to Sentry, depending on the CORS setup of the application the SDK is added to. This is especially relvant for users who use tunnel and forward the SDK requests to a proxy server.

ref: https://linear.app/getsentry/project/chore-alignextend-user-agents-795bfddfa217/overview

seer-by-sentry[bot] reacted with hooray emoji
@Lms24 Lms24 self-assigned this Oct 14, 2025
@Lms24 Lms24 requested a review from AbhiPrasad October 14, 2025 15:07
@Lms24 Lms24 changed the title (削除) feat(core): Send user-agent header with envelope requests (削除ここまで) (追記) feat(core): Send user agent header with envelope requests (追記ここまで) Oct 14, 2025
@Lms24 Lms24 requested review from a team, chargome and cleptric and removed request for a team October 14, 2025 15:12
@Lms24 Lms24 force-pushed the lms/feat-core-send-user-agent-envelope-requests branch from 0c5731c to 8b51d2e Compare October 14, 2025 15:17
cursor[bot]

This comment was marked as outdated.

Copy link
Contributor

github-actions bot commented Oct 14, 2025
edited
Loading

size-limit report 📦

Path Size % Change Change
@sentry/browser 24.63 kB - -
@sentry/browser - with treeshaking flags 23.11 kB - -
@sentry/browser (incl. Tracing) 40.97 kB - -
@sentry/browser (incl. Tracing, Profiling) 45.26 kB - -
@sentry/browser (incl. Tracing, Replay) 79.29 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 68.97 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 83.99 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 96.16 kB - -
@sentry/browser (incl. Feedback) 41.3 kB - -
@sentry/browser (incl. sendFeedback) 29.29 kB - -
@sentry/browser (incl. FeedbackAsync) 34.22 kB - -
@sentry/react 26.31 kB - -
@sentry/react (incl. Tracing) 42.97 kB - -
@sentry/vue 29.11 kB - -
@sentry/vue (incl. Tracing) 42.75 kB - -
@sentry/svelte 24.64 kB - -
CDN Bundle 26.9 kB - -
CDN Bundle (incl. Tracing) 41.62 kB - -
CDN Bundle (incl. Tracing, Replay) 77.87 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 83.35 kB - -
CDN Bundle - uncompressed 78.86 kB - -
CDN Bundle (incl. Tracing) - uncompressed 123.44 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 238.48 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 251.24 kB - -
@sentry/nextjs (client) 45.11 kB - -
@sentry/sveltekit (client) 41.4 kB - -
@sentry/node-core 50.81 kB +0.12% +60 B 🔺
@sentry/node 157.87 kB +0.05% +67 B 🔺
@sentry/node - without tracing 92.69 kB +0.07% +62 B 🔺
@sentry/aws-serverless 106.41 kB +0.07% +65 B 🔺

View base workflow run

Copy link
Contributor

github-actions bot commented Oct 14, 2025
edited
Loading

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,069 - 9,643 -6%
GET With Sentry 1,390 15% 1,422 -2%
GET With Sentry (error only) 6,241 69% 6,216 +0%
POST Baseline 1,217 - 1,219 -0%
POST With Sentry 523 43% 561 -7%
POST With Sentry (error only) 1,073 88% 1,071 +0%
MYSQL Baseline 3,382 - 3,392 -0%
MYSQL With Sentry 513 15% 477 +8%
MYSQL With Sentry (error only) 2,746 81% 2,748 -0%

View base workflow run

@Lms24 Lms24 changed the title (削除) feat(core): Send user agent header with envelope requests (削除ここまで) (追記) feat(core): Send user agent header with envelope requests in server SDKs (追記ここまで) Oct 15, 2025
@Lms24 Lms24 changed the title (削除) feat(core): Send user agent header with envelope requests in server SDKs (削除ここまで) (追記) feat(core): Send user-agent header with envelope requests in server SDKs (追記ここまで) Oct 15, 2025
Copy link
Member

@chargome chargome left a comment

Choose a reason for hiding this comment

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

LGTM!

@Lms24 Lms24 force-pushed the lms/feat-core-send-user-agent-envelope-requests branch from cddc6e4 to 90bc132 Compare October 28, 2025 10:14
@Lms24 Lms24 merged commit e35ca9d into develop Oct 28, 2025
195 checks passed
@Lms24 Lms24 deleted the lms/feat-core-send-user-agent-envelope-requests branch October 28, 2025 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@cursor cursor[bot] cursor[bot] left review comments

@chargome chargome chargome approved these changes

@AbhiPrasad AbhiPrasad Awaiting requested review from AbhiPrasad

@cleptric cleptric Awaiting requested review from cleptric

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /