Gauss
Sane defaults for statsd timers.
Installation
Add this line to your application's Gemfile:
gem 'gauss'
And then execute:
$ bundle
Or install it yourself as:
$ gem install gauss
Usage
You can configure it to use an app prefix, or it will just use the name of the Rails app (or no prefix if it's not a Rails app).
# in application.rb
Gauss::prefix = "GreatRailsApp"
Then you can either use an env var to set the server (ENV["STATSD_SERVER"]) or you can configure it manually
# also in application.rb
Gauss::server = "mystats.greatco.com"
Then in your application code, you can include the Gauss module in a class, and wrap a block with benchmark
# model.rb
class Model < ActiveRecord::Base
include Gauss
def do_something_complex
benchmark { 1 + 1 }
end
end
Now in statsd you'll see Graphite > Stats > Timers > great_rails_app > model > do_something_complex
Enjoy
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request