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..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 @@ -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.logger.error('Error recording broadcasted logger') + end end end end