diff --git a/config/initializers/honeybadger.rb b/config/initializers/honeybadger.rb index 5792eb410..11ac2ca33 100644 --- a/config/initializers/honeybadger.rb +++ b/config/initializers/honeybadger.rb @@ -12,6 +12,13 @@ COMPONENT_FINGERPRINTS = { "internal" => "internal" }.freeze +HONEYBADGER_EXCEPTIONS_TO_IGNORE = [ + ActiveRecord::QueryCanceled, + ActiveRecord::RecordNotFound, + Pundit::NotAuthorizedError, + RateLimitChecker::LimitReached, +].freeze + Rails.application.reloader.to_prepare do # https://docs.honeybadger.io/lib/ruby/gem-reference/configuration.html Honeybadger.configure do |config| @@ -25,8 +32,8 @@ Rails.application.reloader.to_prepare do # Logging allows us to fill in gaps if we need to when errors get discarded. config.send_data_at_exit = false - config.exceptions.ignore += - config.request.filter_keys += %w[authorization] + config.exceptions.ignore += HONEYBADGER_EXCEPTIONS_TO_IGNORE + config.request.filter_keys += %w[authorization] config.sidekiq.attempt_threshold = 10 config.breadcrumbs.enabled = true diff --git a/spec/initializers/honeybadger_spec.rb b/spec/initializers/honeybadger_spec.rb index 2e412ee4d..d07d414ab 100644 --- a/spec/initializers/honeybadger_spec.rb +++ b/spec/initializers/honeybadger_spec.rb @@ -5,6 +5,20 @@ describe Honeybadger do include_examples "#sets_correct_honeybadger_fingerprint", error_key, fingerprint end + context "when configuration is loaded" do + it "ignores requested exceptions" do + exceptions_to_ignore = [ + ActiveRecord::QueryCanceled, + ActiveRecord::RecordNotFound, + Pundit::NotAuthorizedError, + RateLimitChecker::LimitReached, + ] + + ignored_exceptions = described_class.config.ruby[:"exceptions.ignore"] + expect(exceptions_to_ignore.all? { |e| ignored_exceptions.include?(e) }).to be(true) + end + end + context "when error is raised from an internal route" do it "sets fingerprint to internal" do notice = Honeybadger::Notice.new(