Class: Bugsnag::Sidekiq

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

Constant Summary collapse

FRAMEWORK_ATTRIBUTES =
{
  :framework => "Sidekiq"
}

Instance Method Summary collapse

Constructor Details

#initializeSidekiq

Returns a new instance of Sidekiq.



10
11
12
13
14
# File 'lib/bugsnag/integrations/sidekiq.rb', line 10

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



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/bugsnag/integrations/sidekiq.rb', line 16

def call(worker, msg, queue)
  begin
    # store msg/queue in thread local state to be read by Bugsnag::Middleware::Sidekiq
    Bugsnag.configuration.set_request_data :sidekiq, { :msg => msg, :queue => queue }

    yield
  rescue Exception => ex
    raise ex if [Interrupt, SystemExit, SignalException].include? ex.class
    Bugsnag.notify(ex, true) do |report|
      report.severity = "error"
      report.severity_reason = {
        :type => Bugsnag::Report::UNHANDLED_EXCEPTION_MIDDLEWARE,
        :attributes => FRAMEWORK_ATTRIBUTES
      }
    end
    raise
  ensure
    Bugsnag.configuration.clear_request_data
  end
end