Sha256: f2922490a42ac5ae2c82a33b49415f879d30f83ebce646a463f4dd2eb279b542

Contents?: true

Size: 1.08 KB

Versions: 8

Compression:

Stored size: 1.08 KB

Contents

require 'honeybadger/plugin'
require 'honeybadger'

module Honeybadger
  module Plugins
    module Sidekiq
      class Middleware
        def call(worker, msg, queue)
          Honeybadger.context.clear!
          Honeybadger::Trace.instrument("#{msg['class']}#perform", { :source => 'sidekiq', :jid => msg['jid'], :class => msg['class'] }) do
            yield
          end
        end
      end

      Plugin.register do
        requirement { defined?(::Sidekiq) }

        execution do
          ::Sidekiq.configure_server do |sidekiq|
            sidekiq.server_middleware do |chain|
              chain.add Middleware
            end
          end

          if defined?(::Sidekiq::VERSION) && ::Sidekiq::VERSION > '3'
            ::Sidekiq.configure_server do |sidekiq|
              sidekiq.error_handlers << lambda {|ex, params|
                return if params['retry'] && params['retry_count'].to_i < config[:'sidekiq.attempt_threshold'].to_i
                Honeybadger.notify_or_ignore(ex, parameters: params)
              }
            end
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
honeybadger-2.1.6.beta.1 lib/honeybadger/plugins/sidekiq.rb
honeybadger-2.1.5 lib/honeybadger/plugins/sidekiq.rb
honeybadger-2.1.4 lib/honeybadger/plugins/sidekiq.rb
honeybadger-2.1.3 lib/honeybadger/plugins/sidekiq.rb
honeybadger-2.1.1 lib/honeybadger/plugins/sidekiq.rb
honeybadger-mubi-2.1.1 lib/honeybadger/plugins/sidekiq.rb
honeybadger-2.1.0 lib/honeybadger/plugins/sidekiq.rb
honeybadger-2.1.0.beta.1 lib/honeybadger/plugins/sidekiq.rb