Skip to content

fix(core): Suppress stack when SentryError isn't an error #5562

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 4 commits into from
Aug 16, 2022

Conversation

lobsterkatie
Copy link
Member

We use SentryErrors in our event processing and sending pipeline both when something has gone legitimately wrong and when we just want to bail on a promise chain. In all cases, however, we log both the message and the stack, at a warning log level, which both clutters the logs and unnecessarily alarms anyone who has logging on.

This fixes that by adding a logLevel property to the SentryError class, which can be read before we log to the console. The default behavior remains the same (log the full error, using logger.warn), but now we have the option of passing 'log' as a second constructor parameter, in order to mark a given SentryError as something which should only be logger.logged and whose stack should be suppressed.

(To answer the inevitable Why now? question, it's because it was making my test app logs really hard to read and it finally drove me one banana too far.)

@github-actions
Copy link
Contributor

github-actions bot commented Aug 10, 2022

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 19.4 KB (+0.09% 🔺)
@sentry/browser - ES5 CDN Bundle (minified) 60.06 KB (+0.11% 🔺)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 17.97 KB (+0.08% 🔺)
@sentry/browser - ES6 CDN Bundle (minified) 52.92 KB (+0.1% 🔺)
@sentry/browser - Webpack (gzipped + minified) 19.77 KB (+0.2% 🔺)
@sentry/browser - Webpack (minified) 64.3 KB (+0.15% 🔺)
@sentry/react - Webpack (gzipped + minified) 19.79 KB (+0.19% 🔺)
@sentry/nextjs Client - Webpack (gzipped + minified) 44.43 KB (+0.1% 🔺)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 25.9 KB (+0.06% 🔺)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 24.28 KB (+0.07% 🔺)

@lobsterkatie lobsterkatie force-pushed the kmclb-be-less-alarmist-with-SentryError branch 2 times, most recently from 8ef3a9d to ff08601 Compare August 11, 2022 00:14
@lobsterkatie lobsterkatie force-pushed the kmclb-be-less-alarmist-with-SentryError branch 2 times, most recently from e3e7016 to 862a83b Compare August 16, 2022 04:05
@lobsterkatie lobsterkatie force-pushed the kmclb-be-less-alarmist-with-SentryError branch from d36a831 to c56310a Compare August 16, 2022 06:45
@lobsterkatie lobsterkatie merged commit 380f483 into master Aug 16, 2022
@lobsterkatie lobsterkatie deleted the kmclb-be-less-alarmist-with-SentryError branch August 16, 2022 07:02
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