Skip to content

Instantly share code, notes, and snippets.

@timdiggins
Forked from loopj/delayedjob-bugsnag.rb
Last active August 29, 2015 14:11
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save timdiggins/190403991c3a98c0f0c6 to your computer and use it in GitHub Desktop.
notify bugsnag when delayed job errors occur
# some references which helped
# http://blog.salsify.com/engineering/delayed-jobs-callbacks-and-hooks-in-rails
# http://stackoverflow.com/a/16639849/109175
# example plugin: https://github.com/collectiveidea/delayed_job/blob/master/lib/delayed/plugins/clear_locks.rb
module Delayed
module Plugins
class Bugsnag < Plugin
callbacks do |lifecycle|
lifecycle.around(:invoke_job) do |job, &block|
begin
block.call(job)
rescue Exception => error
::Bugsnag.auto_notify(error)
raise
end
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