Sha256: 0f4f12068568351701f871d292140cf916368f04709c40cf4860c6a849bc3e38

Contents?: true

Size: 1.17 KB

Versions: 4

Compression:

Stored size: 1.17 KB

Contents

require 'delayed_job'
require 'honeybadger'

module Honeybadger
  module Plugins
    module DelayedJob
      class Plugin < ::Delayed::Plugin
        callbacks do |lifecycle|
          lifecycle.around(:invoke_job) do |job, &block|
            begin
              ::Honeybadger::Trace.instrument("#{job.payload_object.class}#perform", {source: 'delayed_job', jid: job.id, class: job.payload_object.class.name}) do
                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
                }
              )
              raise error
            ensure
              ::Honeybadger.context.clear!
            end
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
honeybadger-2.0.0.beta.4 lib/honeybadger/plugins/delayed_job/plugin.rb
honeybadger-2.0.0.beta.3 lib/honeybadger/plugins/delayed_job/plugin.rb
honeybadger-2.0.0.beta.2 lib/honeybadger/plugins/delayed_job/plugin.rb
honeybadger-2.0.0.beta.1 lib/honeybadger/plugins/delayed_job/plugin.rb