forked from resque/resque
/
hoptoad.rb
40 lines (36 loc) · 1.18 KB
/
hoptoad.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
require 'hoptoad_notifier'
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/hoptoad'
#
# Resque::Failure::Multiple.classes = [Resque::Failure::Redis, Resque::Failure::Hoptoad]
# Resque::Failure.backend = Resque::Failure::Multiple
#
# Once you've configured resque to use the Hoptoad failure backend,
# you'll want to setup an initializer to configure the Hoptoad.
#
# HoptoadNotifier.configure do |config|
# config.api_key = 'your_key_here'
# end
# For more information see https://github.com/thoughtbot/hoptoad_notifier
class Hoptoad < 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 save
HoptoadNotifier.notify_or_ignore(exception,
:parameters => {
:payload_class => payload['class'].to_s,
:payload_args => payload['args'].inspect
}
)
end
end
end
end