Class: Resque::Failure::Hoptoad

Inherits:
Base
  • Object
show all
Defined in:
lib/resque/failure/hoptoad.rb

Overview

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 github.com/thoughtbot/hoptoad_notifier

Instance Attribute Summary

Attributes inherited from Base

#exception, #payload, #queue, #worker

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

all, clear, #initialize, #log, remove, requeue, url

Constructor Details

This class inherits a constructor from Resque::Failure::Base

Class Method Details

.countObject



27
28
29
30
31
# File 'lib/resque/failure/hoptoad.rb', line 27

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

Instance Method Details

#saveObject



33
34
35
36
37
38
39
40
# File 'lib/resque/failure/hoptoad.rb', line 33

def save
  HoptoadNotifier.notify_or_ignore(exception,
    :parameters => {
      :payload_class => payload['class'].to_s,
      :payload_args => payload['args'].inspect
    }
  )
end