Class: Appsignal::Hooks::ShoryukenMiddleware

Inherits:
Object
  • Object
show all
Defined in:
lib/appsignal/hooks/shoryuken.rb

Instance Method Summary collapse

Instance Method Details

#call(worker_instance, queue, sqs_msg, body) ⇒ Object


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/appsignal/hooks/shoryuken.rb', line 4

def call(worker_instance, queue, sqs_msg, body)
   = {
    :queue => queue
  }
  exclude_keys = [ :job_class, :queue_name, :arguments ]
  .merge!(body.reject{ |key| exclude_keys.member?(key.to_sym) })
  .merge!(sqs_msg.attributes)

  options = {
    :class => body['job_class'],
    :method => 'perform',
    :metadata => 
  }
  options[:params] = body['arguments'] if body.key?('arguments')
  options[:queue_start] = Time.at(sqs_msg.attributes['SentTimestamp'].to_i / 1000) if sqs_msg.attributes.key?('SentTimestamp')

  Appsignal.monitor_transaction('perform_job.shoryuken', options) do
    yield
  end
end