From 8f76e2676a472462f8356c436f8cfed3bfc5a9a9 Mon Sep 17 00:00:00 2001 From: Nathan Appere Date: Thu, 14 Mar 2024 11:40:15 +0000 Subject: [PATCH 1/2] hotfix: prevent exception in record_one_broadcast_with_new_relic --- .../active_support_broadcast_logger/instrumentation.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/instrumentation.rb b/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/instrumentation.rb index 1e5c9c37db..98a0541105 100644 --- a/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/instrumentation.rb +++ b/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/instrumentation.rb @@ -5,9 +5,13 @@ module NewRelic::Agent::Instrumentation module ActiveSupportBroadcastLogger def record_one_broadcast_with_new_relic(*args) - broadcasts[1..-1].each { |broadcasted_logger| broadcasted_logger.instance_variable_set(:@skip_instrumenting, true) } - yield - broadcasts.each { |broadcasted_logger| broadcasted_logger.instance_variable_set(:@skip_instrumenting, false) } + if broadcasts && broadcasts[1..-1] + broadcasts[1..-1].each { |broadcasted_logger| broadcasted_logger.instance_variable_set(:@skip_instrumenting, true) } + yield + broadcasts.each { |broadcasted_logger| broadcasted_logger.instance_variable_set(:@skip_instrumenting, false) } + else + ::NewRelic::Agent.record_custom_event('NR Error - record_one_broadcast_with_new_relic - nil broadcasts', {}) + end end end end From 9665e9a831e0449617dc29bdf7d2d6afee608bf3 Mon Sep 17 00:00:00 2001 From: Nathan Appere Date: Fri, 22 Mar 2024 16:49:25 +0100 Subject: [PATCH 2/2] Fix error reporting --- .../active_support_broadcast_logger/instrumentation.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/instrumentation.rb b/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/instrumentation.rb index 98a0541105..3443fff98c 100644 --- a/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/instrumentation.rb +++ b/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/instrumentation.rb @@ -10,7 +10,7 @@ def record_one_broadcast_with_new_relic(*args) yield broadcasts.each { |broadcasted_logger| broadcasted_logger.instance_variable_set(:@skip_instrumenting, false) } else - ::NewRelic::Agent.record_custom_event('NR Error - record_one_broadcast_with_new_relic - nil broadcasts', {}) + NewRelic::Agent.logger.error('Error recording broadcasted logger') end end end