Sha256: db6ebb9d4cb177c5b748d74dd0be4e7781184d9874f0d4edf61bcd76422efe1f

Contents?: true

Size: 1.06 KB

Versions: 25

Compression:

Stored size: 1.06 KB

Contents

require "resque"
require "resque/failure/multiple"

module Bugsnag
  class Resque < ::Resque::Failure::Base
    def self.configure(&block)
      add_failure_backend
      Bugsnag.configure(&block)
    end

    def self.add_failure_backend
      return if ::Resque::Failure.backend == self

      # Ensure resque is using a "Multiple" failure backend
      unless ::Resque::Failure.backend < ::Resque::Failure::Multiple
        original_backend = ::Resque::Failure.backend
        ::Resque::Failure.backend = ::Resque::Failure::Multiple
        ::Resque::Failure.backend.classes ||= []
        ::Resque::Failure.backend.classes << original_backend
      end

      # Add Bugsnag failure backend
      unless ::Resque::Failure.backend.classes.include?(self)
        ::Resque::Failure.backend.classes << self
      end
    end

    def save
      Bugsnag.auto_notify(exception, {:context => "resque##{queue}", :payload => payload})
    end
  end
end

# For backwards compatibility
Resque::Failure::Bugsnag = Bugsnag::Resque

# Auto-load the failure backend
Bugsnag::Resque.add_failure_backend

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
bugsnag-2.5.1 lib/bugsnag/resque.rb
bugsnag-2.5.0 lib/bugsnag/resque.rb
bugsnag-2.4.1 lib/bugsnag/resque.rb
bugsnag-2.4.0 lib/bugsnag/resque.rb
bugsnag-2.3.0 lib/bugsnag/resque.rb
bugsnag-2.2.2 lib/bugsnag/resque.rb
bugsnag-2.2.1 lib/bugsnag/resque.rb
bugsnag-2.2.0 lib/bugsnag/resque.rb
bugsnag-2.1.0 lib/bugsnag/resque.rb
bugsnag-2.0.3 lib/bugsnag/resque.rb
bugsnag-2.0.2 lib/bugsnag/resque.rb
bugsnag-2.0.1 lib/bugsnag/resque.rb
bugsnag-2.0.0 lib/bugsnag/resque.rb
bugsnag-1.8.8 lib/bugsnag/resque.rb
bugsnag-1.8.7 lib/bugsnag/resque.rb
bugsnag-1.8.6 lib/bugsnag/resque.rb
bugsnag-1.8.5 lib/bugsnag/resque.rb
bugsnag-1.8.4 lib/bugsnag/resque.rb
bugsnag-1.8.3 lib/bugsnag/resque.rb
bugsnag-1.8.2 lib/bugsnag/resque.rb