From 835edc321256168219e8d2e358484218b772e028 Mon Sep 17 00:00:00 2001 From: Erich Soares Machado Date: Tue, 10 Dec 2024 14:52:36 -0500 Subject: [PATCH] Ensure that tests pass on Active Support 6.1 --- .../active_support/span_subscriber_test.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/instrumentation/active_support/test/opentelemetry/instrumentation/active_support/span_subscriber_test.rb b/instrumentation/active_support/test/opentelemetry/instrumentation/active_support/span_subscriber_test.rb index 79e97d99f..6beab546f 100644 --- a/instrumentation/active_support/test/opentelemetry/instrumentation/active_support/span_subscriber_test.rb +++ b/instrumentation/active_support/test/opentelemetry/instrumentation/active_support/span_subscriber_test.rb @@ -201,7 +201,7 @@ def finish(name, id, payload) describe 'instrument' do after do - ActiveSupport::Notifications.notifier.all_listeners_for(notification_name).each do |listener| + ActiveSupport::Notifications.notifier.listeners_for(notification_name).each do |listener| ActiveSupport::Notifications.unsubscribe(listener) end end @@ -396,6 +396,12 @@ def finish(name, id, payload) end it 'finishes spans even when block subscribers blow up' do + # This scenario cannot be exercised reliably on Active Support < 7.0 since the #finish method + # will never be called by the notifier if another subscriber raises an error. + # + # See this PR for additional details: https://github.com/rails/rails/pull/43282 + skip 'Notifications will be broken in this scenario on Active Support < 7.0' if ActiveSupport.version < Gem::Version.new("7.0") + ActiveSupport::Notifications.subscribe(notification_pattern) { raise 'boom' } OpenTelemetry::Instrumentation::ActiveSupport.subscribe(tracer, notification_pattern) @@ -409,6 +415,12 @@ def finish(name, id, payload) end it 'finishes spans even when complex subscribers blow up' do + # This scenario cannot be exercised reliably on Active Support < 7.0 since the #finish method + # will never be called by the notifier if another subscriber raises an error. + # + # See this PR for additional details: https://github.com/rails/rails/pull/43282 + skip 'Notifications will be broken in this scenario on Active Support < 7.0' if ActiveSupport.version < Gem::Version.new("7.0") + ActiveSupport::Notifications.subscribe(notification_pattern, CrashingEndSubscriber.new) OpenTelemetry::Instrumentation::ActiveSupport.subscribe(tracer, notification_pattern)