Created
February 20, 2013 22:18
-
-
Save pejmanjohn/5000200 to your computer and use it in GitHub Desktop.
Notify Honeybadger of errors in DelayedJob workers
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
| # Notify Honeybadger of errors in DelayedJob workers | |
| # in /config/initializers/ | |
| # http://stackoverflow.com/a/14172132/1332687, https://gist.github.com/2223758 | |
| # modified | |
| module Delayed | |
| module Plugins | |
| class Honeybadger < Plugin | |
| module Notify | |
| def error(job, error) | |
| ::Honeybadger.notify( | |
| :error_class => error.class.name, | |
| :error_message => "#{error.class.name}: #{error.message}", | |
| :parameters => { | |
| :failed_job => job.inspect, | |
| } | |
| ) | |
| super if defined?(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::Honeybadger |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment