Sha256: 58e26b4548328c72d0acdc2fa26fdb1bde1a47b371de903a6e014c1be5f07ae2

Contents?: true

Size: 1.36 KB

Versions: 3

Compression:

Stored size: 1.36 KB

Contents

module Honeybadger
  module Integrations
    module DelayedJob
      class Plugin < ::Delayed::Plugin
        callbacks do |lifecycle|
          lifecycle.around(:invoke_job) do |job, &block|
            begin
              if defined?(::Honeybadger::Monitor)
                ::Honeybadger::Monitor::Trace.instrument("#{job.payload_object.class}#perform", { :source => 'delayed_job', :jid => job.id, :class => job.payload_object.class.name }) do
                  block.call(job)
                end
              else
                block.call(job)
              end
            rescue Exception => error
              ::Honeybadger.notify_or_ignore(
                :error_class   => error.class.name,
                :error_message => "#{ error.class.name }: #{ error.message }",
                :backtrace     => error.backtrace,
                  :context       => {
                  :job_id        => job.id,
                  :handler       => job.handler,
                  :last_error    => job.last_error,
                  :attempts      => job.attempts,
                  :queue         => job.queue
                }
              ) if job.attempts.to_i >= ::Honeybadger.configuration.delayed_job_attempt_threshold.to_i
              raise error
            ensure
              ::Honeybadger.context.clear!
            end
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
honeybadger-1.16.7 lib/honeybadger/integrations/delayed_job/plugin.rb
honeybadger-1.16.6 lib/honeybadger/integrations/delayed_job/plugin.rb
honeybadger-1.16.5 lib/honeybadger/integrations/delayed_job/plugin.rb