Yabeda plugin to collect essential metrics for database query performance and connection pool stats.
Install the gem and add to the application's Gemfile by executing:
$ bundle add yabeda-activerecord
Launch/restart your application and that's it: metrics are being collected.
To expose metrics Don't forget to also add one of Yabeda adapters to your Gemfile.
Metric | Type | Tags | Description |
---|---|---|---|
queries_total |
counter | config, kind, cached, async | Total number of SQL queries issued by application via ActiveRecord |
query_duration |
histogram | config, kind, cached, async | Duration for SQL queries generated by ActiveRecord |
Metric | Type | Tags | Description |
---|---|---|---|
connection_pool_size |
gauge | config | Connection pool size |
connection_pool_connections |
gauge | config | Total number of connections currently created in the pool (sum of busy, dead, and idle). |
connection_pool_busy |
gauge | config | Number of connections that has been checked out by some thread and are in use now. |
connection_pool_dead |
gauge | config | Number of lost connections for the pool. A lost connection can occur if a programmer forgets to checkin a connection at the end of a thread or a thread dies unexpectedly. |
connection_pool_idle |
gauge | config | Number of free connections, that are available for checkout. |
connection_pool_waiting |
gauge | config | Number of threads waiting for a connection to become available for checkout. |
connection_pool_checkout_timeout |
gauge | config | Checkout waiting timeout in seconds |
config
— database configuration name in thedatabase.yml
kind
— query kind, usually referring to action over model. E.g.Post Load
cached
—true
if query wasn't executed against the database, results was retrieved from in-memory cache.async
—true
if query was loaded in background viaload_async
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
.
Bug reports and pull requests are welcome on GitHub at https://github.com/yabeda-rb/yabeda-activerecord.
-
Bump version number in
lib/yabeda/activerecord/version.rb
In case of pre-releases keep in mind rubygems/rubygems#3086 and check version with command like
Gem::Version.new(Yabeda::ActiveRecord::VERSION).to_s
-
Fill
CHANGELOG.md
with missing changes, add header with version and date. -
Make a commit:
git add lib/yabeda/active_record/version.rb CHANGELOG.md version=$(ruby -r ./lib/yabeda/active_record/version.rb -e "puts Gem::Version.new(Yabeda::ActiveRecord::VERSION)") git commit --message="${version}: " --edit
-
Create annotated tag:
git tag v${version} --annotate --message="${version}: " --edit --sign
-
Fill version name into subject line and (optionally) some description (list of changes will be taken from changelog and appended automatically)
-
Push it:
git push --follow-tags
-
GitHub Actions will create a new release, build and push gem into RubyGems! You're done!
Bug reports and pull requests are welcome on GitHub at https://github.com/yabeda-rb/yabeda-activerecord.
The gem is available as open source under the terms of the MIT License.