From c50997658ca70937f3ec32b3185a9d90aaabb26e Mon Sep 17 00:00:00 2001 From: Saiqul Haq Date: Sun, 30 Jan 2022 22:49:28 +0700 Subject: [PATCH 1/2] feat: print async_handler class to the log --- lib/rollbar/notifier.rb | 9 ++++++--- spec/rollbar_spec.rb | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/lib/rollbar/notifier.rb b/lib/rollbar/notifier.rb index c6253c46..6715f72f 100644 --- a/lib/rollbar/notifier.rb +++ b/lib/rollbar/notifier.rb @@ -901,9 +901,12 @@ def log_instance_link(data) return unless data[:uuid] uuid_url = Util.uuid_rollbar_url(data, configuration) - log_info( - "[Rollbar] Details: #{uuid_url} (only available if report was successful)" - ) + info_message = "[Rollbar] Details: #{uuid_url} (only available if report was successful)" + if configuration.async_handler + async_handler = configuration.async_handler.class == Class ? configuration.async_handler : configuration.async_handler.class + info_message += ". With async handler = #{async_handler}" + end + log_info(info_message) end def via_failsafe?(item) diff --git a/spec/rollbar_spec.rb b/spec/rollbar_spec.rb index 525af1ab..628de218 100644 --- a/spec/rollbar_spec.rb +++ b/spec/rollbar_spec.rb @@ -1798,6 +1798,16 @@ def backtrace Rollbar.configure(&:use_sucker_punch) Rollbar.error(exception) end + + it "shows 'Rollbar::Delay::SuckerPunch' on the log" do + Rollbar.configure do |config| + config.use_sucker_punch + config.transmit = false + end + + expect(Rollbar.notifier).to receive(:log_info).with(/With async handler = Rollbar::Delay::SuckerPunch/) + Rollbar.notifier.info('info', 'foo bar') + end end describe '#use_shoryuken', :if => defined?(Shoryuken) do @@ -1808,6 +1818,16 @@ def backtrace Rollbar.configure(&:use_shoryuken) Rollbar.error(exception) end + + it "shows 'Rollbar::Delay::Shoryuken' on the log" do + Rollbar.configure do |config| + config.use_shoryuken + config.transmit = false + end + + expect(Rollbar.notifier).to receive(:log_info).with(/With async handler = Rollbar::Delay::Shoryuken/) + Rollbar.notifier.info('info', 'foo bar') + end end describe '#use_sidekiq', :if => defined?(Sidekiq) do @@ -1828,6 +1848,16 @@ def backtrace Rollbar.error(exception) end + + it "shows 'Rollbar::Delay::Sidekiq' on the log" do + Rollbar.configure do |config| + config.use_sidekiq + config.transmit = false + end + + expect(Rollbar.notifier).to receive(:log_info).with(/With async handler = Rollbar::Delay::Sidekiq/) + Rollbar.notifier.info('info', 'foo bar') + end end describe '#use_thread' do @@ -1863,6 +1893,16 @@ def backtrace expect(thread.priority).to eq(custom_priority) thread.join end + + it "shows 'Rollbar::Delay::Thread' on the log" do + Rollbar.configure do |config| + config.use_thread + config.transmit = false + end + + expect(Rollbar.notifier).to receive(:log_info).with(/With async handler = Rollbar::Delay::Thread/) + Rollbar.notifier.info('info', 'foo bar') + end end end From 0f5711d4eb56063312f7f8cfcad5d458d41bf397 Mon Sep 17 00:00:00 2001 From: Saiqul Haq Date: Mon, 31 Jan 2022 00:04:22 +0700 Subject: [PATCH 2/2] fix: should check use_async first before printing the async handler to the log --- lib/rollbar/notifier.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rollbar/notifier.rb b/lib/rollbar/notifier.rb index 6715f72f..d354271e 100644 --- a/lib/rollbar/notifier.rb +++ b/lib/rollbar/notifier.rb @@ -902,7 +902,7 @@ def log_instance_link(data) uuid_url = Util.uuid_rollbar_url(data, configuration) info_message = "[Rollbar] Details: #{uuid_url} (only available if report was successful)" - if configuration.async_handler + if configuration.use_async && configuration.async_handler async_handler = configuration.async_handler.class == Class ? configuration.async_handler : configuration.async_handler.class info_message += ". With async handler = #{async_handler}" end