Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Rollbar::ActiveJob out of the plugin #1149

Merged
merged 1 commit into from
Jan 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 33 additions & 33 deletions lib/rollbar/plugins/active_job.rb
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
Rollbar.plugins.define('active_job') do
dependency { !configuration.disable_monkey_patch }
dependency { !configuration.disable_action_mailer_monkey_patch }
module Rollbar
# Report any uncaught errors in a job to Rollbar and reraise
module ActiveJob
def self.included(base)
base.send :rescue_from, Exception do |exception|
job_data = {
:job => self.class.name,
:use_exception_level_filters => true
}

execute do
module Rollbar
# Report any uncaught errors in a job to Rollbar and reraise
module ActiveJob
def self.included(base)
base.send :rescue_from, Exception do |exception|
job_data = {
:job => self.class.name,
:use_exception_level_filters => true
}
# When included in ActionMailer, the handler is called twice.
# This detects the execution that has the expected state.
if defined?(ActionMailer::Base) && self.class.ancestors.include?(ActionMailer::Base)
job_data[:action] = action_name
job_data[:params] = @params

# When included in ActionMailer, the handler is called twice.
# This detects the execution that has the expected state.
if defined?(ActionMailer::Base) && self.class.ancestors.include?(ActionMailer::Base)
job_data[:action] = action_name
job_data[:params] = @params
Rollbar.error(exception, job_data)

Rollbar.error(exception, job_data)

# This detects other supported integrations.
elsif defined?(arguments)
job_data[:arguments] = \
if self.class.respond_to?(:log_arguments?) && !self.class.log_arguments?
arguments.map(&Rollbar::Scrubbers.method(:scrub_value))
else
arguments
end
job_data[:job_id] = job_id if defined?(job_id)

Rollbar.error(exception, job_data)
# This detects other supported integrations.
elsif defined?(arguments)
job_data[:arguments] = \
if self.class.respond_to?(:log_arguments?) && !self.class.log_arguments?
arguments.map(&Rollbar::Scrubbers.method(:scrub_value))
else
arguments
end
job_data[:job_id] = job_id if defined?(job_id)

raise exception
end
Rollbar.error(exception, job_data)
end

raise exception
end
end
end
end

Rollbar.plugins.define('active_job') do
dependency { !configuration.disable_monkey_patch }
dependency { !configuration.disable_action_mailer_monkey_patch }

execute do
if defined?(ActiveSupport) && ActiveSupport.respond_to?(:on_load)
ActiveSupport.on_load(:action_mailer) do
if defined?(ActionMailer::MailDeliveryJob) # Rails >= 6.0
Expand Down
Loading