Tracking Sidekiq workers exceptions with Errbit/Airbrake

If you've set up Errbit/Airbrake and you use Sidekiq, by default you would expect, that Errbit tracks things that happen in Sidekiq workers as well. Unfortunately it doesn't.

In order to make Sidekiq retry failed jobs in needs to catch and handle exceptions on its own. And that's the reason why you need a bit of "magic" to make it work with Errbit. You need to add an custom error handler that will notify Errbit app about errors that occured in Sidekiq workers.

To do so, just create an initializer like this:

# Errbit error catching for Sidekiq workers
Sidekiq.configure_server do |config|
  config.error_handlers << { |ex,ctx_hash| Airbrake.notify_or_ignore(ex, ctx_hash) }

And that's all!

Categories: Default, Rails, Ruby, Software


  1. Use `Airbrake.notify_or_ignore` instead!

    Sidekiq.configure_server do |config|
    config.error_handlers << { |exception, context| Airbrake.notify_or_ignore(exception, parameters: context) }

  2. You’re absolutely right ;) Thanks for the update!

  3. I’m noticing that many times the arguments for the Sidekiq job don’t make it to Errbit – the Errbit parameters tab remains empty, which makes it hard to debug. Any ideas?

Leave a Reply

Your email address will not be published. Required fields are marked *


Copyright © 2024 Closer to Code

Theme by Anders NorenUp ↑