Sha256: 72516dc674fd3b90ec432497d5c0b9e5e072aeacc63f804a8e03687d282b4814

Contents?: true

Size: 1.13 KB

Versions: 11

Compression:

Stored size: 1.13 KB

Contents

require 'delayed_job'

# See Issue #99
unless defined?(Delayed::Plugin)
  raise LoadError, "bugsnag requires delayed_job > 3.x"
end

::Bugsnag.configuration.internal_middleware.use(::Bugsnag::Middleware::DelayedJob)

module Delayed
  module Plugins
    class Bugsnag < ::Delayed::Plugin
      callbacks do |lifecycle|
        lifecycle.around(:invoke_job) do |job, *args, &block|
          begin
            ::Bugsnag.configuration.app_type = 'delayed_job'
            ::Bugsnag.configuration.set_request_data(:delayed_job, job)
            block.call(job, *args)
          rescue Exception => exception
            ::Bugsnag.notify(exception, true) do |report|
              report.severity = "error"
              report.severity_reason = {
                :type => ::Bugsnag::Report::UNHANDLED_EXCEPTION_MIDDLEWARE,
                :attributes => {
                  :framework => "DelayedJob"
                }
              }
            end
            raise exception
          ensure
            ::Bugsnag.configuration.clear_request_data
          end
        end
      end
    end
  end
end

Delayed::Worker.plugins << Delayed::Plugins::Bugsnag

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
bugsnag-6.15.0 lib/bugsnag/integrations/delayed_job.rb
bugsnag-6.14.0 lib/bugsnag/integrations/delayed_job.rb
bugsnag-6.13.1 lib/bugsnag/integrations/delayed_job.rb
bugsnag-6.13.0 lib/bugsnag/integrations/delayed_job.rb
bugsnag-6.12.2 lib/bugsnag/integrations/delayed_job.rb
bugsnag-6.12.1 lib/bugsnag/integrations/delayed_job.rb
bugsnag-6.12.0 lib/bugsnag/integrations/delayed_job.rb
bugsnag-6.11.1 lib/bugsnag/integrations/delayed_job.rb
bugsnag-6.11.0 lib/bugsnag/integrations/delayed_job.rb
bugsnag-6.10.0 lib/bugsnag/integrations/delayed_job.rb
bugsnag-6.9.0 lib/bugsnag/integrations/delayed_job.rb