Skip to content

feat(core): Add client outcomes for breadcrumbs buffer #15082

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
merged 2 commits into from
Jan 23, 2025

Conversation

AbhiPrasad
Copy link
Member

@AbhiPrasad AbhiPrasad commented Jan 20, 2025

ref getsentry/team-sdks#116

This PR implements a new client discard reason for buffer_overflow. This will be used to track when the internal breadcrumbs buffer overflows for the new logs product that we are working on. This is documented in develop here: getsentry/sentry-docs#12395

Note: The reason we have buffer_overflow as a separate item to queue_overflow is that in the future when we send log items in envelopes we'll increment queue_overflow for the transport queue. We want to differentiate between the transport queue and the internal buffer explicitly.

Copy link
Contributor

github-actions bot commented Jan 20, 2025

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 23.02 KB +0.13% +29 B 🔺
@sentry/browser - with treeshaking flags 22.91 KB +0.15% +33 B 🔺
@sentry/browser (incl. Tracing) 35.74 KB +0.08% +29 B 🔺
@sentry/browser (incl. Tracing, Replay) 72.54 KB +0.04% +28 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 66.09 KB +0.05% +30 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 76.79 KB +0.04% +27 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 88.79 KB +0.03% +27 B 🔺
@sentry/browser (incl. Feedback) 39.22 KB +0.07% +27 B 🔺
@sentry/browser (incl. sendFeedback) 27.65 KB +0.09% +24 B 🔺
@sentry/browser (incl. FeedbackAsync) 32.41 KB +0.08% +26 B 🔺
@sentry/react 25.7 KB +0.13% +32 B 🔺
@sentry/react (incl. Tracing) 38.52 KB +0.09% +32 B 🔺
@sentry/vue 27.09 KB +0.11% +28 B 🔺
@sentry/vue (incl. Tracing) 37.48 KB +0.08% +29 B 🔺
@sentry/svelte 23.14 KB +0.11% +26 B 🔺
CDN Bundle 24.39 KB +0.08% +18 B 🔺
CDN Bundle (incl. Tracing) 36.05 KB +0.07% +25 B 🔺
CDN Bundle (incl. Tracing, Replay) 70.69 KB +0.05% +33 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 75.83 KB +0.04% +27 B 🔺
CDN Bundle - uncompressed 71.27 KB +0.09% +64 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 106.95 KB +0.06% +64 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 217.8 KB +0.03% +64 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 230.33 KB +0.03% +64 B 🔺
@sentry/nextjs (client) 38.63 KB +0.08% +28 B 🔺
@sentry/sveltekit (client) 36.26 KB +0.08% +28 B 🔺
@sentry/node 156.25 KB +0.03% +43 B 🔺
@sentry/node - without tracing 97.39 KB +0.05% +40 B 🔺
@sentry/aws-serverless 106.8 KB +0.04% +39 B 🔺

View base workflow run

@AbhiPrasad AbhiPrasad marked this pull request as ready for review January 21, 2025 17:53
@AbhiPrasad AbhiPrasad requested review from mydea, a team and s1gr1d and removed request for a team January 21, 2025 17:53
Comment on lines +482 to +486
this._breadcrumbs.push(mergedBreadcrumb);
if (this._breadcrumbs.length > maxCrumbs) {
this._breadcrumbs = this._breadcrumbs.slice(-maxCrumbs);
this._client?.recordDroppedEvent('buffer_overflow', 'log_item');
}
Copy link
Member

Choose a reason for hiding this comment

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

Do we even need to push the breadcrumb if the length is already overflowing? 🤔
Correct me if I understood it wrong.

Suggested change
this._breadcrumbs.push(mergedBreadcrumb);
if (this._breadcrumbs.length > maxCrumbs) {
this._breadcrumbs = this._breadcrumbs.slice(-maxCrumbs);
this._client?.recordDroppedEvent('buffer_overflow', 'log_item');
}
if (this._breadcrumbs.length >= maxCrumbs) {
this._client?.recordDroppedEvent('buffer_overflow', 'log_item');
} else {
this._breadcrumbs.push(mergedBreadcrumb);
}

Copy link
Member Author

Choose a reason for hiding this comment

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

I chose to keep the old behaviour of always pushing a breadcrumb, and conditionally calling truncating logic.

If we think about the buffer always trying to maintain max capacity, this makes the most sense. I don't think it's too much of a cost to keep the extra element in the buffer.

@AbhiPrasad AbhiPrasad merged commit 9622bba into develop Jan 23, 2025
146 checks passed
@AbhiPrasad AbhiPrasad deleted the abhi-breadcrumb-client-outcome branch January 23, 2025 14:33
AbhiPrasad added a commit that referenced this pull request Jan 23, 2025
ref getsentry/team-sdks#116

This PR implements a new client discard reason for `buffer_overflow`.
This will be used to track when the internal breadcrumbs buffer
overflows for the new logs product that we are working on. This is
documented in develop here:
getsentry/sentry-docs#12395

Note: The reason we have `buffer_overflow` as a separate item to
`queue_overflow` is that in the future when we send log items in
envelopes we'll increment `queue_overflow` for the transport queue. We
want to differentiate between the transport queue and the internal
buffer explicitly.
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.

2 participants