Sha256: c0e92d4ace6dda5539a7bc609e596a846674a7c18339bbd016ed03342f5982ab

Contents?: true

Size: 1.6 KB

Versions: 23

Compression:

Stored size: 1.6 KB

Contents

if defined?(::Que)
  handler = proc do |error, job|
    begin
      job = job.dup # Make sure the original job object is not mutated.

      Bugsnag.notify(error, true) do |report|
        job[:error_count] += 1

        # If the job was scheduled using ActiveJob then unwrap the job details for clarity:
        if job[:job_class] == "ActiveJob::QueueAdapters::QueAdapter::JobWrapper"
          wrapped_job = job[:args].last
          wrapped_job = wrapped_job.each_with_object({}) { |(k, v), result| result[k.to_sym] = v } # Symbolize keys

          # Align key names with keys in `job`
          wrapped_job[:queue] = wrapped_job.delete(:queue_name)
          wrapped_job[:args]  = wrapped_job.delete(:arguments)

          job.merge!(wrapper_job_class: job[:job_class], wrapper_job_id: job[:job_id]).merge!(wrapped_job)
        end

        report.add_tab(:job, job)
        report.severity = 'error'
        report.severity_reason = {
          :type => Bugsnag::Report::UNHANDLED_EXCEPTION_MIDDLEWARE,
          :attributes => {
            :framework => 'Que'
          }
        }
      end
    rescue => e
      # Que supresses errors raised by its error handler to avoid killing the worker. Log them somewhere:
      Bugsnag.configuration.warn("Failed to notify Bugsnag of error in Que job (#{e.class}): #{e.message} \n#{e.backtrace[0..9].join("\n")}")
      raise
    end
  end

  if Que.respond_to?(:error_notifier=)
    Bugsnag.configuration.app_type ||= "que"
    Que.error_notifier = handler
  elsif Que.respond_to?(:error_handler=)
    Bugsnag.configuration.app_type ||= "que"
    Que.error_handler = handler
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
bugsnag-6.11.1 lib/bugsnag/integrations/que.rb
bugsnag-6.11.0 lib/bugsnag/integrations/que.rb
bugsnag-6.10.0 lib/bugsnag/integrations/que.rb
bugsnag-6.9.0 lib/bugsnag/integrations/que.rb
bugsnag-6.8.0 lib/bugsnag/integrations/que.rb
bugsnag-6.7.3 lib/bugsnag/integrations/que.rb
bugsnag-6.7.2 lib/bugsnag/integrations/que.rb
bugsnag-6.7.1 lib/bugsnag/integrations/que.rb
bugsnag-6.7.0 lib/bugsnag/integrations/que.rb
bugsnag-6.6.4 lib/bugsnag/integrations/que.rb
bugsnag-6.6.3 lib/bugsnag/integrations/que.rb
bugsnag-6.6.2 lib/bugsnag/integrations/que.rb
bugsnag-6.6.1 lib/bugsnag/integrations/que.rb
bugsnag-6.6.0 lib/bugsnag/integrations/que.rb
bugsnag-6.5.0 lib/bugsnag/integrations/que.rb
bugsnag-6.4.0 lib/bugsnag/integrations/que.rb
bugsnag-6.3.0 lib/bugsnag/integrations/que.rb
bugsnag-6.3.0.beta.0 lib/bugsnag/integrations/que.rb
bugsnag-6.2.0 lib/bugsnag/integrations/que.rb
bugsnag-6.1.1 lib/bugsnag/integrations/que.rb