yabeda-rb / yabeda-activerecord

Yabeda plugin to collect query performance metrics and connection pool statistics
MIT License
19 stars 4 forks source link

`Yabeda::ActiveRecord`

Gem Version Tests status

Yabeda plugin to collect essential metrics for database query performance and connection pool stats.

Sponsored by Evil Martians

Installation

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.

Metrics

Query performance

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

Connection pool stats

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

Tags

Development

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.

Releasing

  1. 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

  2. Fill CHANGELOG.md with missing changes, add header with version and date.

  3. 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
  4. Create annotated tag:

    git tag v${version} --annotate --message="${version}: " --edit --sign
  5. Fill version name into subject line and (optionally) some description (list of changes will be taken from changelog and appended automatically)

  6. Push it:

    git push --follow-tags
  7. GitHub Actions will create a new release, build and push gem into RubyGems! You're done!

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/yabeda-rb/yabeda-activerecord.

License

The gem is available as open source under the terms of the MIT License.