Group all PG::TRDeadlockDetected and PG::QueryCanceled errors together (#5681) [deploy]

This commit is contained in:
Molly Struve 2020-01-23 17:54:46 -05:00 committed by GitHub
parent 656e404097
commit 25e985cfce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 7 deletions

View file

@ -1,6 +1,16 @@
# Can be used to implement more programatic error handling
# https://docs.honeybadger.io/lib/ruby/getting-started/ignoring-errors.html#ignore-programmatically
MESSAGE_FINGERPRINTS = {
"BANNED" => "banned",
"Rack::Timeout::RequestTimeoutException" => "rack_timeout",
"PG::QueryCanceled" => "pg_query_canceled"
}.freeze
COMPONENT_FINGERPRINTS = {
"internal" => "internal"
}.freeze
Honeybadger.configure do |config|
config.api_key = ApplicationConfig["HONEYBADGER_API_KEY"]
config.revision = ApplicationConfig["HEROKU_SLUG_COMMIT"]
@ -16,12 +26,10 @@ Honeybadger.configure do |config|
config.before_notify do |notice|
notice.fingerprint = if notice.error_message&.include?("SIGTERM") && notice.component&.include?("fetch_all_rss")
notice.error_message
elsif notice.error_message&.include?("BANNED")
"banned"
elsif notice.error_message&.include?("Rack::Timeout::RequestTimeoutException")
"rack_timeout"
elsif notice.component&.include?("internal")
"internal"
elsif (msg_key = MESSAGE_FINGERPRINTS.keys.detect { |k, _v| notice.error_message&.include?(k) })
MESSAGE_FINGERPRINTS[msg_key]
elsif (cmp_key = COMPONENT_FINGERPRINTS.keys.detect { |k, _v| notice.component&.include?(k) })
COMPONENT_FINGERPRINTS[cmp_key]
end
end
end

View file

@ -32,7 +32,7 @@ describe Honeybadger do
end
context "when error is raised from an internal route" do
it "halts notification" do
it "sets fingerprint to internal" do
notice = Honeybadger::Notice.new(
described_class.config, component: "internal/feedback_messages"
)
@ -40,4 +40,14 @@ describe Honeybadger do
expect(notice.fingerprint).to eq("internal")
end
end
context "when a PG::QueryCanceled error is raised" do
it "sets fingerprint to pg_query_cancel" do
notice = Honeybadger::Notice.new(
described_class.config, error_message: "ActionView::Template::Error: PG::QueryCanceled:"
)
described_class.config.before_notify_hooks.first.call(notice)
expect(notice.fingerprint).to eq("pg_query_canceled")
end
end
end