Skip to content

Commit

Permalink
3724 – Testing ways to better error handle RetryLimitHit (Metrics) (#394
Browse files Browse the repository at this point in the history
)

* try to access the original exception for RetryLimitHit

The Exception class has a method .cause (since Ruby 2.1), with that
method we can access the original error.cause
https://ruby-doc.org/3.0.5/Exception.html

We want to see if this can help us gather more info on our exception,
however it could create duplicate data and just make it more noisy

* add config.sidekiq.report_after_job_retries = true
  • Loading branch information
vasconsaurus authored Sep 26, 2023
1 parent abacdf1 commit 8457348
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions config/initializers/02_sentry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@

# Any exceptions we want to prevent sending to Sentry
config.excluded_exceptions += ['Pender::Exception::RetryLater']

# report_after_job_retries when turned on, the SDK will only report the exception after all retries have failed.
config.sidekiq.report_after_job_retries = true
end
8 changes: 4 additions & 4 deletions config/initializers/03_sidekiq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
Sidekiq.configure_server do |config|
config.redis = redis_config

config.death_handlers << ->(job, ex) do
if ex.is_a?(Pender::Exception::RetryLater)
ex = Pender::Exception::RetryLimitHit.new(ex)
config.death_handlers << ->(job, original_exception) do
if original_exception.is_a?(Pender::Exception::RetryLater)
limit_hit_exception = Pender::Exception::RetryLimitHit.new(original_exception)
end
PenderSentry.notify(ex, {job: job})
PenderSentry.notify(limit_hit_exception, {job: job, original_exception: original_exception.cause})
end
end

Expand Down

0 comments on commit 8457348

Please sign in to comment.