Home

Awesome

Yabeda::ActiveRecord

Gem Version Tests status

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

<a href="https://evilmartians.com/?utm_source=yabeda-activerecord"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://evilmartians.com/badges/sponsored-by-evil-martians_v2.0_for-dark-bg@2x.png"> <img alt="Sponsored by Evil Martians" src="https://evilmartians.com/badges/sponsored-by-evil-martians_v2.0@2x.png" width="236" height="54"> </picture> </a>

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

MetricTypeTagsDescription
queries_totalcounterconfig, kind, cached, asyncTotal number of SQL queries issued by application via ActiveRecord
query_durationhistogramconfig, kind, cached, asyncDuration for SQL queries generated by ActiveRecord

Connection pool stats

MetricTypeTagsDescription
connection_pool_sizegaugeconfigConnection pool size
connection_pool_connectionsgaugeconfigTotal number of connections currently created in the pool (sum of busy, dead, and idle).
connection_pool_busygaugeconfigNumber of connections that has been checked out by some thread and are in use now.
connection_pool_deadgaugeconfigNumber 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_idlegaugeconfigNumber of free connections, that are available for checkout.
connection_pool_waitinggaugeconfigNumber of threads waiting for a connection to become available for checkout.
connection_pool_checkout_timeoutgaugeconfigCheckout 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.