Skip to content

Conversation

AbhiPrasad
Copy link
Member

We've seen some cases where our browser logs are hitting size limits. I suspect this is because we don't have any robust size tracking mechanisms in the browser sdk.

image

This refactors our log flushing mechanisms in the SDK to unify everything between the browser client and server runtime client. This also means the browser SDK gets a weight tracking mechanism for buffering, which should help with making sure we don't run into size issues with logs.

Given metrics has the same issue, I included it in this refactor.

@AbhiPrasad AbhiPrasad requested review from a team and chargome October 9, 2025 21:35
@AbhiPrasad AbhiPrasad self-assigned this Oct 9, 2025
@AbhiPrasad AbhiPrasad requested review from andreiborza and removed request for a team October 9, 2025 21:35
Copy link
Contributor

github-actions bot commented Oct 9, 2025

size-limit report 📦

Path Size % Change Change
@sentry/browser 24.64 kB +0.7% +170 B 🔺
@sentry/browser - with treeshaking flags 23.14 kB +0.79% +181 B 🔺
@sentry/browser (incl. Tracing) 40.8 kB +0.32% +129 B 🔺
@sentry/browser (incl. Tracing, Replay) 79.16 kB +0.16% +126 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 68.87 kB +0.26% +175 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 83.86 kB +0.18% +144 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 96.03 kB +0.14% +133 B 🔺
@sentry/browser (incl. Feedback) 41.33 kB +0.38% +153 B 🔺
@sentry/browser (incl. sendFeedback) 29.3 kB +0.56% +161 B 🔺
@sentry/browser (incl. FeedbackAsync) 34.26 kB +0.45% +152 B 🔺
@sentry/react 26.35 kB +0.63% +163 B 🔺
@sentry/react (incl. Tracing) 42.79 kB +0.41% +172 B 🔺
@sentry/vue 29.13 kB +0.49% +140 B 🔺
@sentry/vue (incl. Tracing) 42.59 kB +0.35% +148 B 🔺
@sentry/svelte 24.66 kB +0.62% +151 B 🔺
CDN Bundle 26.94 kB +0.71% +189 B 🔺
CDN Bundle (incl. Tracing) 41.47 kB +0.45% +182 B 🔺
CDN Bundle (incl. Tracing, Replay) 77.76 kB +0.24% +184 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 83.23 kB +0.24% +192 B 🔺
CDN Bundle - uncompressed 78.95 kB +0.59% +458 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 122.95 kB +0.38% +460 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 238.11 kB +0.2% +460 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 250.87 kB +0.19% +460 B 🔺
@sentry/nextjs (client) 44.85 kB +0.31% +138 B 🔺
@sentry/sveltekit (client) 41.21 kB +0.4% +163 B 🔺
@sentry/node-core 50.78 kB -0.04% -20 B 🔽
@sentry/node 154.4 kB -0.01% -13 B 🔽
@sentry/node - without tracing 92.65 kB -0.02% -17 B 🔽
@sentry/aws-serverless 106.35 kB -0.03% -28 B 🔽

View base workflow run

Copy link
Contributor

github-actions bot commented Oct 9, 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,986 - 9,382 -4%
GET With Sentry 1,376 15% 1,389 -1%
GET With Sentry (error only) 6,048 67% 6,217 -3%
POST Baseline 1,177 - 1,190 -1%
POST With Sentry 496 42% 524 -5%
POST With Sentry (error only) 1,022 87% 1,064 -4%
MYSQL Baseline 3,186 - 3,343 -5%
MYSQL With Sentry 391 12% 486 -20%
MYSQL With Sentry (error only) 2,596 81% 2,752 -6%

View base workflow run

Copy link
Member

@andreiborza andreiborza left a comment

Choose a reason for hiding this comment

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

LGTM

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.

Nice refactor, thanks for adding!

): void {
// @ts-expect-error - TypeScript can't narrow generic hook types to match specific overloads, but we know this is type-safe
client.on(flushHook, () => {
client[weightProperty] = 0;
Copy link
Member

@Lms24 Lms24 Oct 10, 2025

Choose a reason for hiding this comment

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

m/h: does still work in our CDN bundles where we mangle private _-prefixed names?

l: Not particularly a fan of extracting this to a function and then accessing private members. Is there a reason for this over adding a private method to the Client class?

Copy link
Member

Choose a reason for hiding this comment

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

alternatively, could we keep the weight property (+whatever else) as variables within the closure of setupWeightBasedFlushing?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah using closure variables is way nicer. Lemme refactor.

Copy link
Member

@andreiborza andreiborza left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

Thanks for making the changes!

@AbhiPrasad AbhiPrasad enabled auto-merge (squash) October 14, 2025 14:29
@AbhiPrasad AbhiPrasad merged commit ac57cec into develop Oct 14, 2025
190 of 191 checks passed
@AbhiPrasad AbhiPrasad deleted the abhi-weight-tracking-browser branch October 14, 2025 14:49
andreiborza pushed a commit to thedanchez/sentry-javascript that referenced this pull request Oct 15, 2025
…ry#17901)

We've seen some cases where our browser logs are hitting size limits. I
suspect this is because we don't have any robust size tracking
mechanisms in the browser sdk.

<img width="1251" height="513" alt="image"
src="https://github.com/user-attachments/assets/2364b984-2b53-4c6a-89e5-0a0e20fa3246"
/>

This refactors our log flushing mechanisms in the SDK to unify
everything between the browser client and server runtime client. This
also means the browser SDK gets a weight tracking mechanism for
buffering, which should help with making sure we don't run into size
issues with logs.

Given metrics has the same issue, I included it in this refactor.
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.

4 participants