Created
January 30, 2013 20:04
-
-
Save loopj/4676358 to your computer and use it in GitHub Desktop.
A delayed_job plugin to automatically notify Bugsnag (https://bugsnag.com) of exceptions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Delayed | |
module Plugins | |
class Bugsnag < Plugin | |
module Notify | |
def error(job, error) | |
::Bugsnag.auto_notify(error) | |
super | |
end | |
end | |
callbacks do |lifecycle| | |
lifecycle.before(:invoke_job) do |job| | |
payload = job.payload_object | |
payload = payload.object if payload.is_a? Delayed::PerformableMethod | |
payload.extend Notify | |
end | |
end | |
end | |
end | |
end | |
Delayed::Worker.plugins << Delayed::Plugins::Bugsnag |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think it would be simpler and cleaner to use the 'around' hook rather than extending the payload. See my fork: https://gist.github.com/red56/190403991c3a98c0f0c6