Class: Appsignal::Integrations::SidekiqErrorHandler Private

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

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Error handler for Sidekiq to report errors from jobs and internal Sidekiq errors.

Instance Method Summary collapse

Instance Method Details

#call(exception, sidekiq_context) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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

def call(exception, sidekiq_context)
  transaction =
    if Appsignal::Transaction.current?
      Appsignal::Transaction.current
    else
      # Sidekiq error outside of the middleware scope.
      # Can be a job JSON parse error or some other error happening in
      # Sidekiq.
      transaction =
        Appsignal::Transaction.create(
          SecureRandom.uuid, # Newly generated job id
          Appsignal::Transaction::BACKGROUND_JOB,
          Appsignal::Transaction::GenericRequest.new({})
        )
      transaction.set_action_if_nil("SidekiqInternal")
      transaction.("sidekiq_error", sidekiq_context[:context])
      transaction.params = { :jobstr => sidekiq_context[:jobstr] }
      transaction
    end

  transaction.set_error(exception)
  Appsignal::Transaction.complete_current!
end