Sha256: dc20dbaa17e2a999da988d69a2d2834807bcfc88645df0994f2b74ff49b11b81

Contents?: true

Size: 903 Bytes

Versions: 23

Compression:

Stored size: 903 Bytes

Contents

module Airbrake
  module Sidekiq
    ##
    # Provides integration with Sidekiq 2 and Sidekiq 3.
    class ErrorHandler
      # rubocop:disable Lint/RescueException
      def call(_worker, context, _queue)
        yield
      rescue Exception => exception
        notify_airbrake(exception, context)
        raise exception
      end
      # rubocop:enable Lint/RescueException

      private

      def notify_airbrake(exception, context)
        params = context.merge(component: 'sidekiq', action: context['class'])
        Airbrake.notify(exception, params)
      end
    end
  end
end

if Sidekiq::VERSION < '3'
  Sidekiq.configure_server do |config|
    config.server_middleware do |chain|
      chain.add(Airbrake::Sidekiq::ErrorHandler)
    end
  end
else
  Sidekiq.configure_server do |config|
    config.error_handlers << Airbrake::Sidekiq::ErrorHandler.new.method(:notify_airbrake)
  end
end

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
airbrake-5.0.1 lib/airbrake/sidekiq/error_handler.rb
airbrake-5.0.0 lib/airbrake/sidekiq/error_handler.rb
airbrake-5.0.0.rc.1 lib/airbrake/sidekiq/error_handler.rb