Module: Airbrake::Rails::ActiveJob

Extended by:
ActiveSupport::Concern
Defined in:
lib/airbrake/rails/active_job.rb

Overview

Enables support for exceptions occurring in ActiveJob jobs.

Class Method Summary collapse

Class Method Details

.notify_airbrake(exception, job) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/airbrake/rails/active_job.rb', line 9

def self.notify_airbrake(exception, job)
  notice = Airbrake.build_notice(exception)
  notice[:context][:component] = 'active_job'
  notice[:context][:action] = job.class.name
  notice[:params].merge!(job.serialize)

  Airbrake.notify(notice)

  raise exception
end

.perform(job, block) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/airbrake/rails/active_job.rb', line 20

def self.perform(job, block)
  timing = Airbrake::Benchmark.measure do
    block.call
  end
rescue StandardError => exception
  Airbrake.notify_queue(
    queue: job.class.name,
    error_count: 1,
    timing: 0.01,
  )
  raise exception
else
  Airbrake.notify_queue(
    queue: job.class.name,
    error_count: 0,
    timing: timing,
  )
end