4

I want to use Bugsnag to report failed Resque jobs. How do I configure it? The documentation specifically mentions integrations with Resque, but offers no guidance as to how.

Do I have to write a Resque::Failure::Bugsnag class? Did someone else already write it so I don't have to?

messanjah
  • 8,977
  • 4
  • 27
  • 40

3 Answers3

4

Adding to Conrad's excellent answer above, I made the following mistake which was preventing Resque jobs from appearing in Bugsnag:

Make sure to append to Resque::Failure::Multiple.classes in your Resque initializer. I was overwriting the array in the Resque initializer, which was probably (arbitrarily) being called after the Bugsnag initializer ran.

i.e., in config/initializers/resque.rb:

Do:

Resque::Failure::Multiple.classes ||= []
Resque::Failure::Multiple.classes << Resque::Failure::Redis
Resque::Failure.backend = Resque::Failure::Multiple

Do not:

Resque::Failure::Multiple.classes = [Resque::Failure::Redis]
Resque::Failure.backend = Resque::Failure::Multiple
the911s
  • 1,824
  • 17
  • 17
3

The Bugsnag ruby gem is set up to automatically integrate with things like Resque. In theory all you need to do is add bugsnag and resque to your Gemfile:

gem "resque"
gem "bugsnag"

and https://github.com/bugsnag/bugsnag-ruby/blob/master/lib/bugsnag/resque.rb will do the integration work for you.

disclaimer: I work for Bugsnag, and commit to the bugsnag rubygem.

Conrad Irwin
  • 1,312
  • 8
  • 13
1

In addition to the answers above, if you are using a different failure backend class (we're using MultipleWithRetrySuppression by https://github.com/lantins/resque-retry#failure-backend), you need to manually add Bugsnag::Resque to the array. For example:

(Resque::Failure::MultipleWithRetrySuppression.classes ||= []).push(
  Resque::Failure::Redis,
  Bugsnag::Resque
)
Resque::Failure.backend = Resque::Failure::MultipleWithRetrySuppression
mdesantis
  • 8,257
  • 4
  • 31
  • 63