Class: Resque::Failure::Sentry

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

Overview

Failure backend for Sentry (using the raven client gem for Sentry). Similar to the Airbrake backend, this sends exceptions raised in Resque jobs to Sentry. To use, add the following to an initializer:

require 'resque/failure/sentry'

Resque::Failure::Multiple.classes = [Resque::Failure::Redis, Resque::Failure::Sentry]
Resque::Failure.backend = Resque::Failure::Multiple

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.count(queue = nil, class_name = nil) ⇒ Object



38
39
40
41
42
# File 'lib/resque/failure/sentry.rb', line 38

def self.count(queue = nil, class_name = nil)
  # We can't get the total # of errors from Sentry so we fake it by
  # asking Resque how many errors it has seen.
  Stat[:failed]
end

.loggerObject



20
21
22
# File 'lib/resque/failure/sentry.rb', line 20

def self.logger
  @logger
end

.logger=(value) ⇒ Object



24
25
26
# File 'lib/resque/failure/sentry.rb', line 24

def self.logger=(value)
  @logger = value
end

Instance Method Details

#saveObject



28
29
30
31
32
33
34
35
36
# File 'lib/resque/failure/sentry.rb', line 28

def save
  options = {}
  options[:logger] = self.class.logger if self.class.logger
  options[:extra] = {
    "Object" => payload['class'],
    "Arguments" => payload['args']
  }
  Raven.capture_exception(exception, options)
end