diff --git a/config/initializers/02_sentry.rb b/config/initializers/02_sentry.rb index 4f1c2653..556bd635 100644 --- a/config/initializers/02_sentry.rb +++ b/config/initializers/02_sentry.rb @@ -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 diff --git a/config/initializers/03_sidekiq.rb b/config/initializers/03_sidekiq.rb index 2065be72..1272fb2b 100644 --- a/config/initializers/03_sidekiq.rb +++ b/config/initializers/03_sidekiq.rb @@ -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