Skip to content

feat: report all warnings to sentry - #26796

Merged
joshuarli merged 4 commits into
masterfrom
feat/report-all-warnings-to-sentry
Jun 29, 2021
Merged

joshuarli merged 4 commits into
masterfrom
feat/report-all-warnings-to-sentry

Conversation

@joshuarli

@joshuarli joshuarli commented Jun 22, 2021 •

Copy link
Copy Markdown
Member

I'd like to start reporting all warnings to Sentry because I feel like there might be a few django deprecation warnings and other things that sneak past the test suite. Also, Django 2.0+ removes more and more of their py2/3 bytes/unicode compat code which we may have been relying on, I would like to also enable -b and see BytesWarning reported to Sentry for some proactive fixes. The method is described in the comments next to _showwarning, h/t to @untitaker for helping me out here.

The default warning behavior is to "print the first occurrence of matching warnings for each location (module + line number) where the warning is issued", so I don't think we'll get blasted with events, but they will slowly and continuously trickle in since we've got a lot of Sentry python processes and there are new ones all the time from k8s.

It will be a little annoying as they'll keep popping up each release, I intend to actively be ignoring warnings for a little while. Also TODO I can proactively discover these warnings from reading k8s logs and come up with a good ignore list before landing this.

TODO:

  • (done) Fix all RemovedInDjango20Warnings as revealed by the test suite.
  • (done) Come up with a pretty good ignorelist based on what I see in k8s logs.
  • (done) Fix majority of obvious and high volume warnings.
  • (done) Enable -b and fix BytesWarnings (enabled now, but not seeing any, may show up very infrequently)
  • (done) Test this on staging, it works locally though.

@joshuarli joshuarli added this to the python-3.8-upgrade milestone Jun 22, 2021
# and capture_message is very limited, so we just log an error here since LOGGING setting
# is already configured to send error logs to the SDK's EventHandler.
def _showwarning(message, category, filename, lineno, file=None, line=None):
_warning_logger.error(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

woudl wrap this in safe_execute and also call the previous value of warnings.showwarning

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ok, no safe_execute necessary I guess

would still call the old showwarning here

@joshuarli

Copy link
Copy Markdown
Member Author

Ok at this point, pretty much this is good to merge once #26900 gets in.

@joshuarli
joshuarli merged commit d9de3cf into master Jun 29, 2021
@joshuarli
joshuarli deleted the feat/report-all-warnings-to-sentry branch June 29, 2021 16:54
joshuarli added a commit that referenced this pull request Jun 29, 2021
joshuarli added a commit that referenced this pull request Jun 29, 2021
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 15, 2021

This branch was successfully deployed

2 active deployments
Preview – storybook — 8b5428af Deployed Jun 25, 2021 by vercel[bot]
Preview – sentry — 8b5428af Deployed Jun 25, 2021 by vercel[bot]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants