Rack::Instrument is a rack middleware for instrumenting request time, total requests, and total requests per path. I am testing with statsd as an instrumenter, but you can use any object that responds to increment or timing.
Add this line to your application's Gemfile:
gem 'rack-instrument'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rack-instrument
require 'rack/instrument'
require 'statsd'
# Instansiate your instrumenter.
statsd = Statsd.new 'localhost'
statsd.namespace = 'myapp'
# Pass the instrumentor along with an Array of the metrics you would
# like.
#
# Metrics
# :request - Increments the total request count.
# :time - Records total request time.
# :path - Increments the total request count per path.
use Rack::Instrument, statsd, [:request, :time, :path]
Check the examples directory for more examples.
- 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