Sha256: b193ff7b77f3e0edd0ca4c012f1142d3c5c8b58b2c487e929ebcae2c3954d2bf

Contents?: true

Size: 983 Bytes

Versions: 2

Compression:

Stored size: 983 Bytes

Contents

require 'sidekiq'

module Bugsnag
  class Sidekiq
    def initialize
      Bugsnag.configuration.internal_middleware.use(Bugsnag::Middleware::Sidekiq)
      Bugsnag.configuration.app_type = "sidekiq"
      Bugsnag.configuration.default_delivery_method = :synchronous
    end

    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

::Sidekiq.configure_server do |config|
  config.server_middleware do |chain|
    if Gem::Version.new(Sidekiq::VERSION) >= Gem::Version.new('3.3.0')
      chain.prepend ::Bugsnag::Sidekiq
    else
      chain.add ::Bugsnag::Sidekiq
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bugsnag-5.3.3 lib/bugsnag/sidekiq.rb
bugsnag-5.3.2 lib/bugsnag/sidekiq.rb