Skip to content

Commit

Permalink
chore: use retry_limit_reached? method
Browse files Browse the repository at this point in the history
  • Loading branch information
GlauberrBatista committed Sep 21, 2023
1 parent 8f5d12f commit 7a338c3
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions sentry-resque/lib/sentry/resque.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,11 @@ def record(queue, worker, payload, &block)
rescue Exception => exception
klass = payload['class'].constantize

if Sentry.configuration.resque.report_after_job_retries && defined?(::Resque::Plugins::Retry) == 'constant' && klass.is_a?(::Resque::Plugins::Retry)
retry_key = klass.redis_retry_key(payload['args'])
retry_attempt = ::Resque.redis.get(retry_key)
raise if Sentry.configuration.resque.report_after_job_retries &&
defined?(::Resque::Plugins::Retry) == 'constant' &&
klass.is_a?(::Resque::Plugins::Retry) &&
!klass.retry_limit_reached?

# If retry_attempt is nil, it means the resque-retry has already called the #clean_retry_key no retries are left
raise unless retry_attempt.nil?
end
::Sentry::Resque.capture_exception(exception, hint: { background: false })
finish_transaction(transaction, 500)
raise
Expand Down

0 comments on commit 7a338c3

Please sign in to comment.