Sha256: a3205b44e8e589de932110a5e4f9e100110d5e66af64e43d0f4bd01a21d26eee

Contents?: true

Size: 935 Bytes

Versions: 4

Compression:

Stored size: 935 Bytes

Contents

module Airbrake
  module Rails
    # Enables support for exceptions occurring in ActiveJob jobs.
    module ActiveJob
      extend ActiveSupport::Concern

      # @return [Array<Regexp>] the list of known adapters
      ADAPTERS = [/Resque/, /Sidekiq/, /DelayedJob/].freeze

      def self.notify_airbrake(exception, job)
        queue_adapter = job.class.queue_adapter.to_s

        # Do not notify twice if a queue_adapter is configured already.
        raise exception if ADAPTERS.any? { |a| a =~ queue_adapter }

        Airbrake.notify(exception) do |notice|
          notice[:context][:component] = 'active_job'
          notice[:context][:action] = job.class.name
          notice[:params] = job.serialize
        end

        raise exception
      end

      included do
        rescue_from(Exception) do |exception|
          Airbrake::Rails::ActiveJob.notify_airbrake(exception, self)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
airbrake-7.3.4 lib/airbrake/rails/active_job.rb
airbrake-7.3.3 lib/airbrake/rails/active_job.rb
airbrake-7.3.2 lib/airbrake/rails/active_job.rb
airbrake-7.3.1 lib/airbrake/rails/active_job.rb