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.57 kB +0.7% +170 B 🔺
@sentry/browser - with treeshaking flags 23.07 kB +0.75% +170 B 🔺
⛔️ @sentry/browser (incl. Tracing) (max: 40.7 kB) 40.72 kB +0.26% +104 B 🔺
@sentry/browser (incl. Tracing, Replay) 79.08 kB +0.13% +100 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 68.8 kB +0.26% +173 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 83.79 kB +0.15% +122 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 95.95 kB +0.15% +136 B 🔺
@sentry/browser (incl. Feedback) 41.26 kB +0.4% +161 B 🔺
@sentry/browser (incl. sendFeedback) 29.23 kB +0.6% +172 B 🔺
⛔️ @sentry/browser (incl. FeedbackAsync) (max: 34 kB) 34.13 kB +0.46% +153 B 🔺
@sentry/react 26.27 kB +0.63% +162 B 🔺
@sentry/react (incl. Tracing) 42.71 kB +0.38% +159 B 🔺
⛔️ @sentry/vue (max: 29 kB) 29.06 kB +0.5% +143 B 🔺
@sentry/vue (incl. Tracing) 42.53 kB +0.34% +140 B 🔺
@sentry/svelte 24.6 kB +0.65% +158 B 🔺
CDN Bundle 26.81 kB +0.68% +180 B 🔺
CDN Bundle (incl. Tracing) 41.34 kB +0.48% +196 B 🔺
CDN Bundle (incl. Tracing, Replay) 77.62 kB +0.23% +177 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 83.09 kB +0.23% +188 B 🔺
CDN Bundle - uncompressed 78.64 kB +0.59% +458 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 122.64 kB +0.38% +460 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 237.8 kB +0.2% +460 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 250.56 kB +0.19% +460 B 🔺
@sentry/nextjs (client) 44.71 kB +0.3% +132 B 🔺
⛔️ @sentry/sveltekit (client) (max: 41 kB) 41.13 kB +0.39% +157 B 🔺
@sentry/node-core 50.72 kB -0.05% -21 B 🔽
@sentry/node 154.34 kB -0.02% -23 B 🔽
@sentry/node - without tracing 92.56 kB -0.03% -26 B 🔽
@sentry/aws-serverless 106.29 kB -0.03% -31 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,844 - 8,903 -1%
GET With Sentry 1,404 16% 1,367 +3%
GET With Sentry (error only) 6,139 69% 6,204 -1%
POST Baseline 1,215 - 1,208 +1%
POST With Sentry 521 43% 526 -1%
POST With Sentry (error only) 1,076 89% 1,069 +1%
MYSQL Baseline 3,374 - 3,350 +1%
MYSQL With Sentry 509 15% 438 +16%
MYSQL With Sentry (error only) 2,705 80% 2,715 -0%

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants