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

Add discard_classes option to support strings & regular expressions and deprecate ignore_classes #597

Merged
merged 8 commits into from
May 20, 2020

Conversation

imjoehaines
Copy link
Contributor

@imjoehaines imjoehaines commented May 15, 2020

Goal

The ignore_classes option currently supports Class constants and Proc. Rails has recently deprecated autoloading in initialization (where Bugsnag is usually configured) which makes Class constants unusable. Support for Proc is powerful but un-ergonomic when simply trying to ignore an error by class name

In order to help bring the Ruby notifier in-line with other notifiers I've added discard_classes as a new option and deprecated the existing ignore_classes option. discard_classes works similarly to ignore_classes, with these differences:

  1. It accepts String or Regexp rather than Class or Proc
  2. It doesn't walk the ancestor chain

Linked issues

Fixes #589

Review

For the submitter, initial self-review:

  • Commented on code changes inline explain the reasoning behind the approach
  • Reviewed the test cases added for completeness and possible points for discussion
  • A changelog entry was added for the goal of this pull request
  • Check the scope of the changeset - is everything in the diff required for the pull request?
  • This pull request is ready for:
    • Initial review of the intended approach, not yet feature complete
    • Structural review of the classes, functions, and properties modified
    • Final review

For the pull request reviewer(s), this changeset has been reviewed for:

  • Consistency across platforms for structures or concepts added or modified
  • Consistency between the changeset and the goal stated above
  • Internal consistency with the rest of the library - is there any overlap between existing interfaces and any which have been added?
  • Usage friction - is the proposed change in usage cumbersome or complicated?
  • Performance and complexity - are there any cases of unexpected O(n^3) when iterating, recursing, flat mapping, etc?
  • Concurrency concerns - if components are accessed asynchronously, what issues will arise
  • Thoroughness of added tests and any missing edge cases
  • Idiomatic use of the language

@imjoehaines imjoehaines marked this pull request as ready for review May 15, 2020 16:26
@imjoehaines imjoehaines force-pushed the support-strings-and-regex-in-ignore-classes branch from 75aed11 to 31f914c Compare May 15, 2020 16:41
@imjoehaines imjoehaines changed the title Support strings and regex in ignore classes Support strings and regeular expressions in ignore_classes May 15, 2020
This accepts Strings and Regexps rather than Classes and Procs,
which is more inline with other Bugsnag notifiers

It also doesn't walk the ancestor chain, which should lead to less
false positives — with regexps especailly, this could be very
dangerous!
@imjoehaines imjoehaines force-pushed the support-strings-and-regex-in-ignore-classes branch from 31f914c to 7d1c30f Compare May 18, 2020 09:12
@imjoehaines imjoehaines changed the title Support strings and regeular expressions in ignore_classes Add discard_classes option to support strings & regular expressions and deprecate ignore_classes May 18, 2020
lib/bugsnag/configuration.rb Outdated Show resolved Hide resolved
lib/bugsnag/middleware/discard_error_class.rb Outdated Show resolved Hide resolved
Having defaults here is problematic for a few reasons, mainly that
if someone is emptying `ignore_classes` then we'll break their app
by re-adding those defaults to `discard_classes`

We can move the values over when `ignore_classes` is removed
@imjoehaines imjoehaines merged commit 8bc9ce0 into next May 20, 2020
@imjoehaines imjoehaines deleted the support-strings-and-regex-in-ignore-classes branch May 20, 2020 13:00
@imjoehaines imjoehaines mentioned this pull request Jul 20, 2020
@pic
Copy link

pic commented Jul 27, 2020

support of Proc would still be useful so in the proc I could check is_a? and still be able to group the exceptions that I want to ignore with a common ancestor. Is there any chance that it will be added again?

@snmaynard
Copy link
Contributor

You should be able to use the newly added on_error Procs to handle that

@ngan
Copy link

ngan commented Nov 2, 2020

So is the suggested way to use on_error for walking ancestors? Or continue using adding a Proc to ignore_classes?

@imjoehaines
Copy link
Contributor Author

So is the suggested way to use on_error for walking ancestors? Or continue using adding a Proc to ignore_classes?

Yeah I'd recommend using on_error for that. If you're already using ignore_classes then it will continue to work for now, but you'll need to migrate eventually

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.

5 participants