Class: Appsignal::Integrations::SidekiqMiddleware Private

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

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.

Constant Summary collapse

EXCLUDED_JOB_KEYS =

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

%w[
  args backtrace class created_at enqueued_at error_backtrace error_class
  error_message failed_at jid retried_at retry wrapped
].freeze

Instance Method Summary collapse

Methods included from Hooks::Helpers

#string_or_inspect, #truncate

Instance Method Details

#call(_worker, item, _queue) ⇒ 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.



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/appsignal/integrations/sidekiq.rb', line 46

def call(_worker, item, _queue)
  job_status = nil
  transaction = Appsignal::Transaction.create(
    item["jid"],
    Appsignal::Transaction::BACKGROUND_JOB,
    Appsignal::Transaction::GenericRequest.new(
      :queue_start => item["enqueued_at"]
    )
  )

  Appsignal.instrument "perform_job.sidekiq" do
    yield
  end
rescue Exception => exception # rubocop:disable Lint/RescueException
  job_status = :failed
  raise exception
ensure
  if transaction
    transaction.set_action_if_nil(formatted_action_name(item))

    params = filtered_arguments(item)
    transaction.params = params if params

    (item).each do |key, value|
      transaction. key, value
    end
    transaction.set_http_or_background_queue_start
    Appsignal::Transaction.complete_current! unless exception

    queue = item["queue"] || "unknown"
    if job_status
      increment_counter "queue_job_count", 1,
        :queue => queue,
        :status => job_status
    end
    increment_counter "queue_job_count", 1,
      :queue => queue,
      :status => :processed
  end
end