Skip to content
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

Updates sentry sdk configuration #6175

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

empty-codes
Copy link
Contributor

What this PR does

Reduce noise in Sentry by filtering out benign / unactionable errors.

  • Upgrades sentry gems to versions 5.22.3 in order to use 'sentry/test_helper'
  • Adds require and include statements for sentry test helper in rails_helper
  • Adds filtering to sentry events before they are sent to Sentry using config.excluded_exceptions and config.before_send
  • Adds sentry_spec to ensure filtering works as expected and normal sentry event sending logic is not affected.

Screenshots

Before changes to sentry.rb:

Only the does not filter out normal events passes:

image

After changes to sentry.rb:

image

- Upgrades sentry gems to versions 5.22.3 in order to use 'sentry/test_helper'
- Adds require and include statements for sentry test helper in `rails_helper`
- Adds filtering to sentry events before they are sent to Sentry using `config.excluded_exceptions` and `config.before_send`
- Adds `sentry_spec` to ensure filtering works as expected and normal sentry event sending logic is not affected.
@empty-codes empty-codes changed the title Updates sentry sdk configuration + Introduces tests: Updates sentry sdk configuration Feb 4, 2025
- Filters `Non-Error promise rejection` errors which are Known errors caused by Microsoft Outlook SafeSearch or bot crawlers that use the CefSharp library.
- Filters `chrome-extension://` errors which like the name implies are caused by user extensions.
@Formasitchijoh
Copy link
Contributor

Hello @empty-codes the failure in your build has been fixed here waiting for it to be merged

# Appends to IGNORE_DEFAULT array of exception classes that should never be sent to Sentry
config.excluded_exceptions += ['WikiApi::PageFetchError'] # error code 429

filter_patterns = [
Copy link
Member

Choose a reason for hiding this comment

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

Hmm...

I don't think I like using pattern matching to filter errors here. I'd rather take it very slowly and only filter out specific error classes that we have a clear understanding of, in terms of why they are happening.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did that because the TypeErrors don't follow the pattern of Ruby / Rails exceptions but I do understand, I'll remove that if case

stacktrace = exception&.stacktrace
if stacktrace
stacktrace.frames.each do |frame|
if frame.function&.include?('@webkit-masked-url')
Copy link
Contributor Author

@empty-codes empty-codes Feb 11, 2025

Choose a reason for hiding this comment

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

What of this check? Should I leave it in? the errors with chrome-extension'are well caused by chrome extensions manipulating the code in ways not meant to, while the webkit-masked url is a webkit bug caused by safari extensions.

These errors are actually part of the ones automatically filtered out by Sentry if we toggle the filter 'Filter out errors known to be caused by browser extensions' in the UI (see their source code here) but since better safe than sorry, I filtered out just these

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also , I added a check for web crawler errors (that caused the ReferenceError: stores is not defined error) this way:

# Ignore web crawler errors
    browser_name = event.tags&.dig(:browser_name)
    return nil if %w[Baiduspider Googlebot].include?(browser_name)

It's also part of the web crawler errors Sentry filters out if we toggle the option, (see their source code here). Baiduspider and Googlebot are the ones I've noticed so I also filtered just these.

Is this okay?

@ragesoss
Copy link
Member

I think we should set this Sentry config aside entirely for now. I want to be really confident that we don't accidentally start losing meaningful errors, and the 429 errors can definitely be potentially meaningful ones.

@empty-codes
Copy link
Contributor Author

I think we should set this Sentry config aside entirely for now. I want to be really confident that we don't accidentally start losing meaningful errors, and the 429 errors can definitely be potentially meaningful ones.

Okay got it! I'll go back to fixing the fixable errors, cause they're still a lot😅

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