Class: Bugsnag::Sidekiq

Inherits:
Object
  • Object
show all
Defined in:
lib/bugsnag/sidekiq.rb

Instance Method Summary collapse

Constructor Details

#initializeSidekiq

Returns a new instance of Sidekiq.



5
6
7
8
9
# File 'lib/bugsnag/sidekiq.rb', line 5

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

Instance Method Details

#call(worker, msg, queue) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/bugsnag/sidekiq.rb', line 11

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