Created
April 20, 2017 12:24
-
-
Save Paxa/7627a85863667b207dd8527c41abcee9 to your computer and use it in GitHub Desktop.
ActiveRecord pool stats for Rails < 5.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unless ActiveRecord::ConnectionAdapters::ConnectionPool.method_defined?(:stat) # will be in Rails 5.1 | |
class ActiveRecord::ConnectionAdapters::ConnectionPool | |
def stat | |
synchronize do | |
{ | |
size: size, | |
connections: @connections.size, | |
busy: @connections.count { |c| c.in_use? && c.owner.alive? }, | |
dead: @connections.count { |c| c.in_use? && !c.owner.alive? }, | |
idle: @connections.count { |c| !c.in_use? }, | |
waiting: num_waiting_in_queue, | |
checkout_timeout: checkout_timeout | |
} | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment