From 43818c7a9fec8bcf0437a7a68b4024290e67e789 Mon Sep 17 00:00:00 2001 From: Adam Renberg Tamm Date: Fri, 8 Nov 2024 13:19:47 +0100 Subject: [PATCH 1/3] Switch to ActiveSupport::Notifications.monotonic_subscribe --- lib/bugsnag/integrations/railtie.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bugsnag/integrations/railtie.rb b/lib/bugsnag/integrations/railtie.rb index c875972a..b18e755a 100644 --- a/lib/bugsnag/integrations/railtie.rb +++ b/lib/bugsnag/integrations/railtie.rb @@ -15,7 +15,7 @@ class Railtie < ::Rails::Railtie # @api private # @param event [Hash] details of the event to subscribe to def event_subscription(event) - ActiveSupport::Notifications.subscribe(event[:id]) do |*, event_id, data| + ActiveSupport::Notifications.monotonic_subscribe(event[:id]) do |*, event_id, data| filtered_data = data.slice(*event[:allowed_data]) filtered_data[:event_name] = event[:id] filtered_data[:event_id] = event_id From b4d8f522461b6ce33f978f5461f1dbc2774d672f Mon Sep 17 00:00:00 2001 From: Khushbu Maheshwari Date: Thu, 9 Apr 2026 21:10:38 +0530 Subject: [PATCH 2/3] monotonic_subscribe was introduced in Rails 6.1+, add condition accordingly --- CHANGELOG.md | 7 +++++++ lib/bugsnag/integrations/railtie.rb | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9100a03..37c3dd20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,13 @@ Changelog ========= +## TBD + +### Enhancements + +* Use `ActiveSupport::Notifications.monotonic_subscribe` on compatible Rails versions + | [#856](https://github.com/bugsnag/bugsnag-ruby/pull/856) + ## v6.29.0 (21 January 2026) ### Enhancements diff --git a/lib/bugsnag/integrations/railtie.rb b/lib/bugsnag/integrations/railtie.rb index b18e755a..ce178254 100644 --- a/lib/bugsnag/integrations/railtie.rb +++ b/lib/bugsnag/integrations/railtie.rb @@ -15,7 +15,9 @@ class Railtie < ::Rails::Railtie # @api private # @param event [Hash] details of the event to subscribe to def event_subscription(event) - ActiveSupport::Notifications.monotonic_subscribe(event[:id]) do |*, event_id, data| + # monotonic_subscribe was introduced in Rails 6.1+, check if it exists + subscription_method = ActiveSupport::Notifications.respond_to?(:monotonic_subscribe) ? :monotonic_subscribe : :subscribe + ActiveSupport::Notifications.send(subscription_method, event[:id]) do |*, event_id, data| filtered_data = data.slice(*event[:allowed_data]) filtered_data[:event_name] = event[:id] filtered_data[:event_id] = event_id From 2587164b29c6d3ec6da50af34d415b8742e160f5 Mon Sep 17 00:00:00 2001 From: Khushbu Maheshwari Date: Mon, 13 Apr 2026 15:01:11 +0530 Subject: [PATCH 3/3] change entry in CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37c3dd20..0c587346 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ Changelog ### Enhancements -* Use `ActiveSupport::Notifications.monotonic_subscribe` on compatible Rails versions +* Use `ActiveSupport::Notifications.monotonic_subscribe` for performance improvement on compatible Rails versions | [#856](https://github.com/bugsnag/bugsnag-ruby/pull/856) ## v6.29.0 (21 January 2026)