Sha256: 3c85c4d75ba1684338f323e65de3b42e9ef61b1c5e6e4fd2a4864e23893f0969

Contents?: true

Size: 986 Bytes

Versions: 10

Compression:

Stored size: 986 Bytes

Contents

require 'sidekiq'

module Bugsnag
  class Sidekiq
    def call(worker, msg, queue)
      begin

        # store msg/queue in thread local state to be read by Bugsnag::Middleware::Sidekiq
        Bugsnag.set_request_data :sidekiq, { :msg => msg, :queue => queue }

        yield
      rescue Exception => ex
        raise ex if [Interrupt, SystemExit, SignalException].include? ex.class
        Bugsnag.auto_notify(ex)
        raise
      ensure
        Bugsnag.clear_request_data
      end
    end
  end
end

if ::Sidekiq::VERSION < '3'
  ::Sidekiq.configure_server do |config|
    config.server_middleware do |chain|
      chain.add ::Bugsnag::Sidekiq
    end
  end
else
  ::Sidekiq.configure_server do |config|
    config.error_handlers << lambda do |ex, ctx|
      Bugsnag.auto_notify(ex, :sidekiq => ctx, :context => "sidekiq##{ctx['queue']}")
    end
  end
end

Bugsnag.configuration.internal_middleware.use(Bugsnag::Middleware::Sidekiq)
Bugsnag.configuration.app_type = "sidekiq"

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
bugsnag-4.0.0 lib/bugsnag/sidekiq.rb
bugsnag-3.0.0 lib/bugsnag/sidekiq.rb
bugsnag-2.8.13 lib/bugsnag/sidekiq.rb
bugsnag-maglev--2.8.12 lib/bugsnag/sidekiq.rb
bugsnag-2.8.12 lib/bugsnag/sidekiq.rb
bugsnag-2.8.11 lib/bugsnag/sidekiq.rb
bugsnag-2.8.10 lib/bugsnag/sidekiq.rb
bugsnag-2.8.9 lib/bugsnag/sidekiq.rb
bugsnag-2.8.8 lib/bugsnag/sidekiq.rb
bugsnag-2.8.7 lib/bugsnag/sidekiq.rb