Skip to content

perf(node): Truncate breadcrumb messages created by console integration #14006

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 3 commits into from
Oct 18, 2024

Conversation

lforst
Copy link
Member

@lforst lforst commented Oct 17, 2024

We got a report that the SDK was consuming a lot of memory. Looking at the heap snapshot I noticed that we are unboundidly storing strings in breadcrumbs, no matter how large they are, leading to the breadcrumbs potentially holding a lot of memory.

Copy link
Contributor

github-actions bot commented Oct 17, 2024

size-limit report 📦

Path Size % Change Change
@sentry/browser 22.73 KB - -
@sentry/browser - with treeshaking flags 21.53 KB - -
@sentry/browser (incl. Tracing) 35.12 KB - -
@sentry/browser (incl. Tracing, Replay) 71.86 KB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 62.26 KB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 76.21 KB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 89 KB - -
@sentry/browser (incl. Tracing, Replay, Feedback, metrics) 90.82 KB - -
@sentry/browser (incl. metrics) 27 KB - -
@sentry/browser (incl. Feedback) 39.87 KB - -
@sentry/browser (incl. sendFeedback) 27.38 KB - -
@sentry/browser (incl. FeedbackAsync) 32.17 KB - -
@sentry/react 25.49 KB - -
@sentry/react (incl. Tracing) 38.09 KB - -
@sentry/vue 26.91 KB - -
@sentry/vue (incl. Tracing) 37.02 KB - -
@sentry/svelte 22.87 KB - -
CDN Bundle 24.11 KB - -
CDN Bundle (incl. Tracing) 36.96 KB - -
CDN Bundle (incl. Tracing, Replay) 71.65 KB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 76.99 KB - -
CDN Bundle - uncompressed 70.7 KB - -
CDN Bundle (incl. Tracing) - uncompressed 109.73 KB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 222.24 KB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 235.46 KB - -
@sentry/nextjs (client) 38.06 KB - -
@sentry/sveltekit (client) 35.74 KB - -
@sentry/node 125.15 KB +0.01% +7 B 🔺
@sentry/node - without tracing 94.25 KB +0.01% +6 B 🔺
@sentry/aws-serverless 103.81 KB +0.01% +7 B 🔺

View base workflow run

@lforst lforst requested review from Lms24 and AbhiPrasad October 17, 2024 08:45
@@ -14,11 +17,17 @@ const _consoleIntegration = (() => {
return;
}

// Truncate the breadcrumb length to max 2KB including the truncated snippet
let formattedMessage: string = util.format.apply(undefined, args);
if (formattedMessage.length > MAX_BREADCRUMB_MSG_LENGTH) {
Copy link
Member

Choose a reason for hiding this comment

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

l: Why not just use truncate from @sentry/utils? :)

Copy link
Member Author

@lforst lforst Oct 18, 2024

Choose a reason for hiding this comment

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

I did not know that existed 🧠 nice

@lforst lforst requested a review from mydea October 18, 2024 07:55
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.

Good change!

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.

suggestion: Can we add a test for this?

wait, I'm realizing you said yesterday that we don't have any tests for this integration. Maybe it's worth to address this as a whole in a separate PR then.

@lforst
Copy link
Member Author

lforst commented Oct 18, 2024

I'm realizing you said yesterday that we don't have any tests for this integration. Maybe it's worth to address this as a whole in a separate PR then.

Fuck it, I'll be a good person for once and add tests 😂

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.

3 participants