Class: Appsignal::Integrations::DelayedPlugin

Inherits:
Delayed::Plugin
  • Object
show all
Defined in:
lib/appsignal/integrations/delayed_job.rb

Class Method Summary collapse

Class Method Details

.invoke_with_instrumentation(job, block) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/appsignal/integrations/delayed_job.rb', line 13

def self.invoke_with_instrumentation(job, block)
  begin
    Appsignal::Transaction.create(SecureRandom.uuid, ENV)
    class_name, method_name = job.name.split('#')
    ActiveSupport::Notifications.instrument(
      'perform_job.delayed_job',
      :class => class_name,
      :method => method_name,
      :priority => job.priority,
      :attempts => job.attempts,
      :queue => job.queue,
      :queue_start => job.created_at
    ) do
      block.call(job)
    end
  rescue Exception => exception
    Appsignal.add_exception(exception)
    raise exception
  ensure
    Appsignal::Transaction.complete_current!
  end
end