messanjah
messanjah

Reputation: 9288

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?

Upvotes: 4

Views: 543

Answers (3)

mdesantis
mdesantis

Reputation: 8517

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

Upvotes: 1

the911s
the911s

Reputation: 1924

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

Upvotes: 4

Conrad Irwin
Conrad Irwin

Reputation: 1312

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.

Upvotes: 3

Related Questions