reinh/statsd — pull request #40 by raykrueger (2013-04-10 21:30:26+00:00)
Title: New statsd interceptor for wrapping instances

This is a pattern I've used in one of the apps I have and figured it
might be a useful contribution.

To use it simply wrap any object and call methods on it as normal.

For instance, if you wanted to time every call to a redis client:

require 'statsd/interceptor'
require 'redis'

statsd = Statsd.new('localhost', 1234)
redis = Statsd::Interceptor.new(Redis.current, statsd)

redis.set "blah", true
redis.get "blah"

Would produce timings such as:
"Redis.get:1|ms" and
"Redis.set:1|ms"

If the target raises any errors an "errors" counter is incremented:
"Redis.get.errors:1|c"
"Redis.set.errors:1|c"