You're right @JordanFeldstein the question was for Airbrake. Funnily I used the same hack for honeybadger and it worked pretty well. I guess Airbrake and Honeybadger have APIs that respond to the same calls (very good thing)
–
lsaffieFeb 22 '14 at 18:01

This plugin is now deprecated for the latest version of Honeybadger.
–
Andrew CP KelleyJul 31 '14 at 22:02

Probably the simplest way to get delayed_job to send through an alert to Airbrake when the job fails is to monkey-patch delayed_job. This allows you to hook into delayed_job's internals, and modify it slightly to alert Airbrake when something goes wrong.

Unfortunately, exactly how to do this will depend on which version of delayed_job you are using, and which version of Airbrake you are using; it will also depend, perhaps, on exactly where within the delayed_job processing you want to hook into the system.

However, probably the simplest example I have seen for how to do what you want is to monkey-patch the handle_failed_job method, as seen here. Note though that this example uses the old Hoptoad system for the alerting, so if you're using a modern Airbrake gem, you'll need to change the code that does the actual notifying to be as described here.

Because of the way Airbrake shows parameters, I'd recommend not sending job.inspect but instead pass a hash. First parse the contents of the failed job: failed_job = YAML.load(job.handler). Then parse it's instance parameters into a hash, which you can pass to the :parameters for airbrake: failed_job.instance_variables.inject({}) { |hsh,v| hsh[v.to_s.gsub(/[^\w]/, '')] = failed_job.instance_variable_get(v); hsh }
–
iainbeestonApr 17 '13 at 2:54

1

You might also want to include the class name of the job in the :parameters too: :class => failed_job.class.name
–
iainbeestonApr 17 '13 at 3:00