Class: RorVsWild::Plugin::ActiveJob

Inherits:
Object
  • Object
show all
Defined in:
lib/rorvswild/plugin/active_job.rb

Class Method Summary collapse

Class Method Details

.around_perform(job, block) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rorvswild/plugin/active_job.rb', line 13

def self.around_perform(job, block)
  RorVsWild.agent.measure_job(job.class.name, parameters: job.arguments) do
    begin
      section = RorVsWild::Section.start
      section.commands << "#{job.class}#perform"
      section.file, section.line = job.method(:perform).source_location
      section.file = RorVsWild.agent.locator.relative_path(section.file)
      block.call
    rescue Exception => ex
      job.rescue_with_handler(ex) or raise
    ensure
      RorVsWild::Section.stop
    end
  end
end

.setup(agent) ⇒ Object



6
7
8
9
10
11
# File 'lib/rorvswild/plugin/active_job.rb', line 6

def self.setup(agent)
  return if @installed
  return unless defined?(::ActiveJob::Base)
  ::ActiveJob::Base.around_perform(&method(:around_perform))
  @installed = true
end