Sha256: 70231fdd21d3cc6c37bf97438a2212aae29fead8ff5a71ccd7076a8b80c3e09a

Contents?: true

Size: 1013 Bytes

Versions: 46

Compression:

Stored size: 1013 Bytes

Contents

module Airbrake
  module Shoryuken
    # Provides integration with Shoryuken.
    class ErrorHandler
      # rubocop:disable Lint/RescueException
      def call(worker, queue, _sqs_msg, body)
        yield
      rescue Exception => exception
        notify_airbrake(exception, worker, queue, body)

        raise exception
      end
      # rubocop:enable Lint/RescueException

      private

      def notify_airbrake(exception, worker, queue, body)
        Airbrake.notify(exception, notice_context(queue, body)) do |notice|
          notice[:context][:component] = 'shoryuken'
          notice[:context][:action] = worker.class.to_s
        end
      end

      def notice_context(queue, body)
        {
          queue: queue,
          body: body.is_a?(Array) ? { batch: body } : { body: body }
        }
      end
    end
  end
end

if defined?(::Shoryuken)
  Shoryuken.configure_server do |config|
    config.server_middleware do |chain|
      chain.add Airbrake::Shoryuken::ErrorHandler
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
airbrake-9.5.5 lib/airbrake/shoryuken.rb
airbrake-9.5.4 lib/airbrake/shoryuken.rb
airbrake-9.5.3 lib/airbrake/shoryuken.rb
airbrake-9.5.2 lib/airbrake/shoryuken.rb
airbrake-9.5.1 lib/airbrake/shoryuken.rb
airbrake-9.5.0 lib/airbrake/shoryuken.rb
airbrake-9.4.5 lib/airbrake/shoryuken.rb
airbrake-9.4.4 lib/airbrake/shoryuken.rb
airbrake-9.4.3 lib/airbrake/shoryuken.rb
airbrake-9.4.2 lib/airbrake/shoryuken.rb
airbrake-9.4.1 lib/airbrake/shoryuken.rb
airbrake-9.4.0 lib/airbrake/shoryuken.rb
airbrake-9.3.0 lib/airbrake/shoryuken.rb
airbrake-9.2.2 lib/airbrake/shoryuken.rb
airbrake-9.2.1 lib/airbrake/shoryuken.rb
airbrake-9.2.0 lib/airbrake/shoryuken.rb
airbrake-9.1.0 lib/airbrake/shoryuken.rb
airbrake-9.0.2 lib/airbrake/shoryuken.rb
airbrake-9.0.1 lib/airbrake/shoryuken.rb
airbrake-9.0.0 lib/airbrake/shoryuken.rb