Skip to content

Commit

Permalink
combine Rack::Timeout::RequestTimeoutErrors with Exceptions in Honeyb…
Browse files Browse the repository at this point in the history
…adger (#5789) [deploy]
  • Loading branch information
mstruve committed Jan 28, 2020
1 parent 82f2281 commit a19ce55
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 38 deletions.
1 change: 1 addition & 0 deletions config/initializers/honeybadger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
MESSAGE_FINGERPRINTS = {
"BANNED" => "banned",
"Rack::Timeout::RequestTimeoutException" => "rack_timeout",
"Rack::Timeout::RequestTimeoutError" => "rack_timeout",
"PG::QueryCanceled" => "pg_query_canceled"
}.freeze

Expand Down
40 changes: 2 additions & 38 deletions spec/initializers/honeybadger_spec.rb
Original file line number Diff line number Diff line change
@@ -1,34 +1,8 @@
require "rails_helper"

describe Honeybadger do
context "when a fetch_all_rss SIGTERM error is raised" do
it "sets fingerprint to error_message" do
notice = Honeybadger::Notice.new(
described_class.config, error_message: "SignalException: SIGTERM", component: "rake fetch_all_rss"
)
described_class.config.before_notify_hooks.first.call(notice)
expect(notice.fingerprint).to eq(notice.error_message)
end
end

context "when BANNED error is raised" do
it "sets fingerprint to banned" do
notice = Honeybadger::Notice.new(
described_class.config, error_message: "RuntimeError: BANNED"
)
described_class.config.before_notify_hooks.first.call(notice)
expect(notice.fingerprint).to eq("banned")
end
end

context "when Rack::Timeout::RequestTimeoutException is raised" do
it "sets fingerprint to rack_timeout" do
notice = Honeybadger::Notice.new(
described_class.config, error_message: "Rack::Timeout::RequestTimeoutException happened"
)
described_class.config.before_notify_hooks.first.call(notice)
expect(notice.fingerprint).to eq("rack_timeout")
end
MESSAGE_FINGERPRINTS.each do |error_key, fingerprint|
include_examples "#sets_correct_honeybadger_fingerprint", error_key, fingerprint
end

context "when error is raised from an internal route" do
Expand All @@ -40,14 +14,4 @@
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
RSpec.shared_examples "#sets_correct_honeybadger_fingerprint" do |error_key, fingerprint|
it "raises an error" do
notice = Honeybadger::Notice.new(
described_class.config, error_message: "CRAP! #{error_key} Bail!"
)
described_class.config.before_notify_hooks.first.call(notice)
expect(notice.fingerprint).to eq(fingerprint)
end
end
1 change: 1 addition & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
Dir[Rails.root.join("spec/models/shared_examples/**/*.rb")].sort.each { |f| require f }
Dir[Rails.root.join("spec/jobs/shared_examples/**/*.rb")].sort.each { |f| require f }
Dir[Rails.root.join("spec/workers/shared_examples/**/*.rb")].sort.each { |f| require f }
Dir[Rails.root.join("spec/initializers/shared_examples/**/*.rb")].sort.each { |f| require f }

# Checks for pending migrations before tests are run.
# If you are not using ActiveRecord, you can remove this line.
Expand Down

0 comments on commit a19ce55

Please sign in to comment.