Skip to content

Commit

Permalink
Ensure that tests pass on Active Support 6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
erichmachado committed Dec 10, 2024
1 parent b8c0fca commit 9791e56
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 'Active Support Notifications will break in these scenarions in Rails < 7.0' if ActiveSupport.version < Gem::Version.new("7.0")

ActiveSupport::Notifications.subscribe(notification_pattern) { raise 'boom' }
OpenTelemetry::Instrumentation::ActiveSupport.subscribe(tracer, notification_pattern)

Expand All @@ -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 'Active Support Notifications will break in these scenarions in Rails < 7.0' if ActiveSupport.version < Gem::Version.new("7.0")

ActiveSupport::Notifications.subscribe(notification_pattern, CrashingEndSubscriber.new)
OpenTelemetry::Instrumentation::ActiveSupport.subscribe(tracer, notification_pattern)

Expand Down

0 comments on commit 9791e56

Please sign in to comment.