Sha256: abc235b6ced8d053ea207def77ec8b74f223eabbd887464572eb5a8c809ef120

Contents?: true

Size: 1.38 KB

Versions: 18

Compression:

Stored size: 1.38 KB

Contents

module Delayed
  module Plugins
    ##
    # Provides integration with Delayed Job.
    # rubocop:disable Lint/RescueException
    class Airbrake < ::Delayed::Plugin
      callbacks do |lifecycle|
        lifecycle.around(:invoke_job) do |job, *args, &block|
          begin
            # Forward the call to the next callback in the callback chain
            block.call(job, *args)
          rescue Exception => exception
            params = job.as_json.merge(
              component: 'delayed_job',
              action: job.payload_object.class.name
            )

            # If DelayedJob is used through ActiveJob, it contains extra info.
            if job.payload_object.respond_to?(:job_data)
              params[:active_job] = job.payload_object.job_data
            end

            ::Airbrake.notify(exception, params)
            raise exception
          end
        end
      end
    end
    # rubocop:enable Lint/RescueException
  end
end

if RUBY_ENGINE == 'jruby' && defined?(Delayed::Backend::ActiveRecord::Job)
  ##
  # Workaround against JRuby bug:
  # https://github.com/jruby/jruby/issues/3338
  # rubocop:disable Style/ClassAndModuleChildren
  class Delayed::Backend::ActiveRecord::Job
    alias old_to_ary to_ary

    def to_ary
      old_to_ary || [self]
    end
  end
  # rubocop:enable Style/ClassAndModuleChildren
end

Delayed::Worker.plugins << Delayed::Plugins::Airbrake

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
airbrake-5.6.1 lib/airbrake/delayed_job/plugin.rb
airbrake-5.6.0 lib/airbrake/delayed_job/plugin.rb
airbrake-5.5.0 lib/airbrake/delayed_job/plugin.rb
airbrake-5.4.5 lib/airbrake/delayed_job/plugin.rb
airbrake-5.4.4 lib/airbrake/delayed_job/plugin.rb
airbrake-5.4.3 lib/airbrake/delayed_job/plugin.rb
airbrake-5.4.2 lib/airbrake/delayed_job/plugin.rb
airbrake-5.4.1 lib/airbrake/delayed_job/plugin.rb
airbrake-5.4.0 lib/airbrake/delayed_job/plugin.rb
airbrake-5.3.0 lib/airbrake/delayed_job/plugin.rb
airbrake-5.2.3 lib/airbrake/delayed_job/plugin.rb
airbrake-5.2.2 lib/airbrake/delayed_job/plugin.rb
airbrake-5.2.1 lib/airbrake/delayed_job/plugin.rb
airbrake-5.2.0 lib/airbrake/delayed_job/plugin.rb
airbrake-5.1.0 lib/airbrake/delayed_job/plugin.rb
airbrake-5.0.5 lib/airbrake/delayed_job/plugin.rb
airbrake-5.0.4 lib/airbrake/delayed_job/plugin.rb
airbrake-5.0.3 lib/airbrake/delayed_job/plugin.rb