Class: Appsignal::Integrations::ShoryukenMiddleware Private

Inherits:
Object
  • Object
show all
Defined in:
lib/appsignal/integrations/shoryuken.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.

Instance Method Summary collapse

Instance Method Details

#call(worker_instance, queue, sqs_msg, body, &block) ⇒ 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.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/appsignal/integrations/shoryuken.rb', line 7

def call(worker_instance, queue, sqs_msg, body, &block)
  transaction = Appsignal::Transaction.create(Appsignal::Transaction::BACKGROUND_JOB)

  Appsignal.instrument("perform_job.shoryuken", &block)
rescue Exception => error # rubocop:disable Lint/RescueException
  transaction.set_error(error)
  raise
ensure
  batch = sqs_msg.is_a?(Array)
  attributes = fetch_attributes(batch, sqs_msg)
  transaction.set_action_if_nil("#{worker_instance.class.name}#perform")
  transaction.add_params_if_nil { fetch_args(batch, sqs_msg, body) }
  transaction.add_tags(attributes)
  transaction.add_tags("queue" => queue)
  transaction.add_tags("batch" => true) if batch

  if attributes.key?("SentTimestamp")
    transaction.set_queue_start(Time.at(attributes["SentTimestamp"].to_i).to_i)
  end

  Appsignal::Transaction.complete_current!
end