Skip to content

Commit

Permalink
Do not report Sidekiq::JobRetry::Skip errors (#1256)
Browse files Browse the repository at this point in the history
These errors would be reported by our Rails error subscriber. This is an
internal Sidekiq error we do not need to report.
  • Loading branch information
tombruijn authored Aug 23, 2024
1 parent 0639452 commit 9ea2d3e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changesets/do-not-report-sidekiq--jobretry--skip-errors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
bump: patch
type: fix
---

Do not report `Sidekiq::JobRetry::Skip` errors. These errors would be reported by our Rails error subscriber. This is an internal Sidekiq error we do not need to report.
12 changes: 12 additions & 0 deletions lib/appsignal/integrations/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ def self.initialize_error_reporter
class RailsErrorReporterSubscriber
class << self
def report(error, handled:, severity:, context: {}, source: nil) # rubocop:disable Lint/UnusedMethodArgument
return if ignored_error?(error)

is_rails_runner = source == "application.runner.railties"
namespace, action_name, tags, custom_data = context_for(context.dup)

Expand All @@ -100,6 +102,16 @@ def report(error, handled:, severity:, context: {}, source: nil) # rubocop:disab

private

IGNORED_ERRORS = [
# We don't need to alert Sidekiq job skip errors.
# This is an internal Sidekiq error.
"Sidekiq::JobRetry::Skip"
].freeze

def ignored_error?(error)
IGNORED_ERRORS.include?(error.class.name)
end

def context_for(context)
tags = {}

Expand Down
11 changes: 11 additions & 0 deletions spec/lib/appsignal/integrations/railtie_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,17 @@ def subscribe(subscriber)
expect(last_transaction).to have_error("ExampleStandardError", "error message")
end

it "ignores Sidekiq::JobRetry::Skip errors" do
require "sidekiq"
require "sidekiq/job_retry"

with_rails_error_reporter do
Rails.error.handle { raise Sidekiq::JobRetry::Skip, "error message" }
end

expect(last_transaction).to_not have_error
end

context "when no transaction is active" do
it "reports the error on a new transaction" do
with_rails_error_reporter do
Expand Down

0 comments on commit 9ea2d3e

Please sign in to comment.