-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggestion: Track ActiveRecord connection pool stats #716
Comments
This comment was marked as outdated.
This comment was marked as outdated.
The data not being in the previous comment was because of |
One more update from me. Based on @tombruijn findings, here is my final setup for the ActiveRecord connection pool probe, working both in Puma workers and everywhere else:
Appsignal::Probes.register(:active_record_connection_pool, lambda do
ActiveRecord::Base.connection_pool.stat.each do |key, value|
hostname = Appsignal.config[:hostname] || Socket.gethostname
Appsignal.set_gauge("active_record_connection_pool_#{key}", value, {hostname:})
end
end)
preload_app!
before_fork do
# Stop AppSignal probes in the Puma main process
Appsignal::Probes.stop
# Deregister AppSignal probe from the Puma main process
Appsignal::Probes.unregister(:active_record_connection_pool)
end
on_worker_boot do |worker_index|
# Register the AppSignal probe in the Puma worker process
Appsignal::Probes.register(:active_record_connection_pool, lambda do
ActiveRecord::Base.connection_pool.stat.each do |key, value|
hostname = Appsignal.config[:hostname] || Socket.gethostname
Appsignal.set_gauge("active_record_connection_pool_#{key}", value, {hostname:, process: worker_index})
end
end)
# Start AppSignal probes in the Puma worker process
Appsignal::Probes.start
end |
A suggestion for a new probe on this library by using this piece of code:
ActiveRecord::Base.connection_pool.stat
The text was updated successfully, but these errors were encountered: