Search code examples
ruby-on-railssidekiq

How to get sidekiq retry_count from inside a job


I am trying to send an alert every time retry_count of a sidekiq job reaches 5(to warn an engineer to check why the worker is failing) and then continued being retried as usual.

Is there a way to get the retry count for a particular job from inside the job?

I could just use:

sidekiq_retry_in do |count|
  (warn engineer here)
  10 * (count + 1) # (i.e. 10, 20, 30, 40)
end

and send a message from in there, but I think its a bit of a hack.

Any ideas? googling didn't surface any results.


Solution

  • There is no way to get the retry count from within the job, by design.