Class: Appsignal::Hooks::SidekiqPlugin Private

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/appsignal/hooks/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

UNKNOWN_ACTION_NAME =

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.

"unknown".freeze
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 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.



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/appsignal/hooks/sidekiq.rb', line 115

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

  Appsignal.instrument "perform_job.sidekiq" do
    begin
      yield
    rescue Exception => exception # rubocop:disable Lint/RescueException
      job_status = :failed
      transaction.set_error(exception)
      raise exception
    end
  end
ensure
  if transaction
    transaction.set_action_if_nil(formatted_action_name(item))
    transaction.params = filtered_arguments(item)
    (item).each do |key, value|
      transaction. key, value
    end
    transaction.set_http_or_background_queue_start
    Appsignal::Transaction.complete_current!
    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