Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure Bugsnag with Resque::Failure?

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?

like image 403
messanjah Avatar asked Feb 10 '23 14:02

messanjah


2 Answers

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
like image 102
the911s Avatar answered Feb 20 '23 17:02

the911s


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.

like image 34
Conrad Irwin Avatar answered Feb 20 '23 18:02

Conrad Irwin