Sha256: fdffdd0bc5b2e96872eda6f79bb4a0a1348fd524e3d8e2ce5d4026e25c503ae1
Contents?: true
Size: 1.93 KB
Versions: 6
Compression:
Stored size: 1.93 KB
Contents
require 'honeybadger/plugin' require 'honeybadger/ruby' module Honeybadger module Plugins module Resque module Extension def around_perform_with_honeybadger(*args) Honeybadger.flush { yield } ensure Honeybadger.context.clear! end def on_failure_with_honeybadger(e, *args) Honeybadger.notify(e, parameters: { job_arguments: args }) if send_exception_to_honeybadger?(e, args) end def send_exception_to_honeybadger?(e, args) return true unless respond_to?(:retry_criteria_valid?) return true if ::Honeybadger.config[:'resque.resque_retry.send_exceptions_when_retrying'] !retry_criteria_valid?(e) rescue => e Honeybadger.notify(e, parameters: { job_arguments: args }) end end module Installer def self.included(base) base.send(:alias_method, :payload_class_without_honeybadger, :payload_class) base.send(:alias_method, :payload_class, :payload_class_with_honeybadger) end def payload_class_with_honeybadger payload_class_without_honeybadger.tap do |klass| unless klass.respond_to?(:around_perform_with_honeybadger) klass.instance_eval do extend(::Honeybadger::Plugins::Resque::Extension) end end end end end Plugin.register do requirement { defined?(::Resque::Job) } requirement do if resque_honeybadger = defined?(::Resque::Failure::Honeybadger) logger.warn("Support for Resque has been moved " \ "to the honeybadger gem. Please remove " \ "resque-honeybadger from your " \ "Gemfile.") end !resque_honeybadger end execution do ::Resque::Job.send(:include, Installer) end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems