Skip to content

Commit

Permalink
Fix Rails 7.1 deprecation warning
Browse files Browse the repository at this point in the history
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 <module:ActiveRecord> 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)
  • Loading branch information
intrip committed Nov 16, 2023
1 parent 3e0698f commit 29df0a3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/yabeda/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 29df0a3

Please sign in to comment.