No commit activity in last 3 years
No release in over 3 years
Exposes a metrics collector to the request environment and flushes the data to statsd when the request is finished. Batches the data to send as few packets as possible.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

 Project Readme

Rack::StatsdBatch

Throw your metrics data into your request env, and on egress it will get pushed to statsd in as few requests as possible.

Setup

Add to your gemfile

gem 'rack-statsd_batch', '~> 0.0.1', require: 'rack/statsd_batch'

Add to your middleware in config/application.rb

config.middleware.use Rack::StatsdBatch, 'statsd-server.myhost.com', 1234

Use

The stats collector is included in your request environment. Access it from your controller:

metrics = request.env['metrics']

There are five message types that map to the statsd backend

metrics.gauge_diff 'registered-users', +1
metrics.gauge 'total_things', 2037
metrics.timing 'render_time_ms', 237
metrics.count 'things_done', 1
metrics.sets 'user_ids', 27