From 29df0a3467886971a51dfb581862fb9db92fd663 Mon Sep 17 00:00:00 2001 From: Jacopo Date: Thu, 16 Nov 2023 17:16:33 +0100 Subject: [PATCH 1/3] Fix Rails 7.1 deprecation warning DEPRECATION WARNING: `connection_pool_list` currently only applies to connection pools in the current role (`writing`). In Rails 7.2, this method will apply to all known pools, regardless of role. To affect only those connections belonging to a specific role, pass the role name as an argument. To switch to the new behavior, pass `:all` as the role name. (called from block (2 levels) in at /Users/jacopobeschi/.rbenv/versions/3.3.0-preview2/lib/ruby/gems/3.3.0+0/gems/yabeda-activerecord-0.1.0/lib/yabeda/active_record.rb:74) --- lib/yabeda/active_record.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/yabeda/active_record.rb b/lib/yabeda/active_record.rb index ba89a1f..e6e985b 100644 --- a/lib/yabeda/active_record.rb +++ b/lib/yabeda/active_record.rb @@ -71,7 +71,12 @@ class Error < StandardError; end # Connection pool metrics collection collect do - connection_pools = ::ActiveRecord::Base.connection_handler.connection_pool_list + connection_pools = \ + if Rails.version >= "7.1" + ::ActiveRecord::Base.connection_handler.connection_pool_list(:all) + else + ::ActiveRecord::Base.connection_handler.connection_pool_list + end connection_pools.each do |connection_pool| stats = connection_pool.stat From 41b40d8ee580ebbe0eeae398b70c202b307be843 Mon Sep 17 00:00:00 2001 From: Jacopo Beschi Date: Tue, 12 Dec 2023 13:06:52 +0100 Subject: [PATCH 2/3] Update lib/yabeda/active_record.rb Co-authored-by: Andrey Novikov --- lib/yabeda/active_record.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/yabeda/active_record.rb b/lib/yabeda/active_record.rb index e6e985b..a5f2325 100644 --- a/lib/yabeda/active_record.rb +++ b/lib/yabeda/active_record.rb @@ -72,7 +72,7 @@ class Error < StandardError; end # Connection pool metrics collection collect do connection_pools = \ - if Rails.version >= "7.1" + if ::ActiveRecord.version >= "7.1" ::ActiveRecord::Base.connection_handler.connection_pool_list(:all) else ::ActiveRecord::Base.connection_handler.connection_pool_list From 544c6db68e89eddc8a3d007e72cfd19e83ed14ec Mon Sep 17 00:00:00 2001 From: Jacopo Beschi Date: Tue, 12 Dec 2023 16:14:58 +0100 Subject: [PATCH 3/3] Update lib/yabeda/active_record.rb Co-authored-by: Andrey Novikov --- lib/yabeda/active_record.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/yabeda/active_record.rb b/lib/yabeda/active_record.rb index a5f2325..de57a20 100644 --- a/lib/yabeda/active_record.rb +++ b/lib/yabeda/active_record.rb @@ -72,7 +72,7 @@ class Error < StandardError; end # Connection pool metrics collection collect do connection_pools = \ - if ::ActiveRecord.version >= "7.1" + if ::ActiveRecord.version >= Gem::Version.new("7.1") ::ActiveRecord::Base.connection_handler.connection_pool_list(:all) else ::ActiveRecord::Base.connection_handler.connection_pool_list