Statsd-middleware is a project mainly written in Ruby, it's free.
Simple middlware to track page hits to Statsd/Graphite
Simple middleware to log hits to StatsD and Graphite
I needed this to also see which servers were serving, so I require https://github.com/efficiency20/ops_middleware
For a typical rails setup
https://github.com/etsy/statsd
I packaged jnunemaker's branch of reinh's statsd gem (from https://github.com/reinh/statsd && https://github.com/jnunemaker/statsd/tree/mine). Just install that until reinh pulls jnunemaker's version and puts it out there
gem install jamster-statsd #
https://github.com/efficiency20/ops_middleware
Uh, you can figure this out I'm sure
I put this above the Initializer (Rails::Initializer.run do |config|
) in environment.rb. This may not be the best spot, but I did have a reason for putting it there, but now I can't remember. You can try it in an initializer also, I suppose.
require 'statsd'
$statsd = Statsd.new('graphite.YOURHOST.com', 8125)
$statsd.namespace="YOURHOST_#{ENV['RAILS_ENV']}"
/app/config/environments/#{Rails.env}.rb
config.middleware.insert 1, "StatsdMiddleware", $statsd
Jason Amster
Thanks to Eric Kastner for Statsd
Thanks to Bryan Helmkamp for ops_middleware
Thanks to John Nunemaker for his post: http://railstips.org/blog/archives/2011/03/21/hi-my-name-is-john/