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, _sidekiq_config = nil) ⇒ 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.

Sidekiq 7.1.5 introduced the third sidekiq_config argument. It is not given on older Sidekiq versions.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/appsignal/integrations/sidekiq.rb', line 31

def call(exception, sidekiq_context, _sidekiq_config = nil)
  if Appsignal::Transaction.current?
    if Appsignal.config[:sidekiq_report_errors] == "all"
      transaction = Appsignal::Transaction.current
      transaction.set_error(exception)
    end
  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(Appsignal::Transaction::BACKGROUND_JOB)
    transaction.set_action_if_nil("SidekiqInternal")
    transaction.("sidekiq_error", sidekiq_context[:context])
    transaction.add_params_if_nil(:jobstr => sidekiq_context[:jobstr])
    transaction.set_error(exception)
  end

  Appsignal::Transaction.complete_current!
end