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

#extract_value, #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.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/appsignal/hooks/sidekiq.rb', line 33

def call(_worker, item, _queue)
  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
      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!
  end
end