|
1 |
| -Rollbar.plugins.define('active_job') do |
2 |
| - dependency { !configuration.disable_monkey_patch } |
3 |
| - dependency { !configuration.disable_action_mailer_monkey_patch } |
| 1 | +module Rollbar |
| 2 | + # Report any uncaught errors in a job to Rollbar and reraise |
| 3 | + module ActiveJob |
| 4 | + def self.included(base) |
| 5 | + base.send :rescue_from, Exception do |exception| |
| 6 | + job_data = { |
| 7 | + :job => self.class.name, |
| 8 | + :use_exception_level_filters => true |
| 9 | + } |
4 | 10 |
|
5 |
| - execute do |
6 |
| - module Rollbar |
7 |
| - # Report any uncaught errors in a job to Rollbar and reraise |
8 |
| - module ActiveJob |
9 |
| - def self.included(base) |
10 |
| - base.send :rescue_from, Exception do |exception| |
11 |
| - job_data = { |
12 |
| - :job => self.class.name, |
13 |
| - :use_exception_level_filters => true |
14 |
| - } |
| 11 | + # When included in ActionMailer, the handler is called twice. |
| 12 | + # This detects the execution that has the expected state. |
| 13 | + if defined?(ActionMailer::Base) && self.class.ancestors.include?(ActionMailer::Base) |
| 14 | + job_data[:action] = action_name |
| 15 | + job_data[:params] = @params |
15 | 16 |
|
16 |
| - # When included in ActionMailer, the handler is called twice. |
17 |
| - # This detects the execution that has the expected state. |
18 |
| - if defined?(ActionMailer::Base) && self.class.ancestors.include?(ActionMailer::Base) |
19 |
| - job_data[:action] = action_name |
20 |
| - job_data[:params] = @params |
| 17 | + Rollbar.error(exception, job_data) |
21 | 18 |
|
22 |
| - Rollbar.error(exception, job_data) |
23 |
| - |
24 |
| - # This detects other supported integrations. |
25 |
| - elsif defined?(arguments) |
26 |
| - job_data[:arguments] = \ |
27 |
| - if self.class.respond_to?(:log_arguments?) && !self.class.log_arguments? |
28 |
| - arguments.map(&Rollbar::Scrubbers.method(:scrub_value)) |
29 |
| - else |
30 |
| - arguments |
31 |
| - end |
32 |
| - job_data[:job_id] = job_id if defined?(job_id) |
33 |
| - |
34 |
| - Rollbar.error(exception, job_data) |
| 19 | + # This detects other supported integrations. |
| 20 | + elsif defined?(arguments) |
| 21 | + job_data[:arguments] = \ |
| 22 | + if self.class.respond_to?(:log_arguments?) && !self.class.log_arguments? |
| 23 | + arguments.map(&Rollbar::Scrubbers.method(:scrub_value)) |
| 24 | + else |
| 25 | + arguments |
35 | 26 | end
|
| 27 | + job_data[:job_id] = job_id if defined?(job_id) |
36 | 28 |
|
37 |
| - raise exception |
38 |
| - end |
| 29 | + Rollbar.error(exception, job_data) |
39 | 30 | end
|
| 31 | + |
| 32 | + raise exception |
40 | 33 | end
|
41 | 34 | end
|
| 35 | + end |
| 36 | +end |
42 | 37 |
|
| 38 | +Rollbar.plugins.define('active_job') do |
| 39 | + dependency { !configuration.disable_monkey_patch } |
| 40 | + dependency { !configuration.disable_action_mailer_monkey_patch } |
| 41 | + |
| 42 | + execute do |
43 | 43 | if defined?(ActiveSupport) && ActiveSupport.respond_to?(:on_load)
|
44 | 44 | ActiveSupport.on_load(:action_mailer) do
|
45 | 45 | if defined?(ActionMailer::MailDeliveryJob) # Rails >= 6.0
|
|
0 commit comments