diff --git a/lib/rollbar/plugins/active_job.rb b/lib/rollbar/plugins/active_job.rb index a0e6e4b6..f0442ec7 100644 --- a/lib/rollbar/plugins/active_job.rb +++ b/lib/rollbar/plugins/active_job.rb @@ -3,11 +3,17 @@ module Rollbar module ActiveJob def self.included(base) base.send :rescue_from, Exception do |exception| + args = if self.class.respond_to?(:log_arguments?) && !self.class.log_arguments? + arguments.map(&Rollbar::Scrubbers.method(:scrub_value)) + else + arguments + end + Rollbar.error(exception, :job => self.class.name, :job_id => job_id, :use_exception_level_filters => true, - :arguments => arguments) + :arguments => args) raise exception end end diff --git a/spec/rollbar/plugins/active_job_spec.rb b/spec/rollbar/plugins/active_job_spec.rb index 7d1c8791..f7c03070 100644 --- a/spec/rollbar/plugins/active_job_spec.rb +++ b/spec/rollbar/plugins/active_job_spec.rb @@ -49,6 +49,23 @@ def perform(exception, job_id) end.to raise_error exception end + it 'scrubs all arguments if job has `log_arguments` disabled' do + allow(TestJob).to receive(:log_arguments?).and_return(false) + + expected_params = { + :job => 'TestJob', + :job_id => job_id, + :use_exception_level_filters => true, + :arguments => ['******', '******', '******'] + } + expect(Rollbar).to receive(:error).with(exception, expected_params) + begin + TestJob.new(1, 2, 3).perform(exception, job_id) + rescue StandardError + nil + end + end + context 'using ActionMailer::DeliveryJob', :if => defined?(ActionMailer::DeliveryJob) do include ActiveJob::TestHelper if defined?(ActiveJob::TestHelper)