Created
March 14, 2011 05:50
-
-
Save brianjlandau/868826 to your computer and use it in GitHub Desktop.
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
| require 'hoptoad_notifier' | |
| require 'resque/failure/base' | |
| module Resque | |
| module Failure | |
| # A Failure backend that sends exceptions raised by jobs to Hoptoad. | |
| # | |
| # To use it, put this code in an initializer, Rake task, or wherever: | |
| # | |
| # require 'resque/failure/simpler_hoptoad' | |
| # Resque::Failure.backend = Resque::Failure::SimplerHoptoad | |
| class SimplerHoptoad < Base | |
| def self.count | |
| # We can't get the total # of errors from Hoptoad so we fake it | |
| # by asking Resque how many errors it has seen. | |
| Stat[:failed] | |
| end | |
| def self.url | |
| 'YOUR_HOPTOAD_PROJECT_URL' | |
| end | |
| def save | |
| payload['args'] = payload['args'].inspect | |
| HoptoadNotifier.notify(exception, { | |
| :component => payload["class"].to_s, | |
| :url => queue.to_s, | |
| :parameters => { | |
| :queue => queue, | |
| :payload => payload | |
| } | |
| }) | |
| end | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment