No commit activity in last 3 years
No release in over 3 years
Provides a framework for sending wall time statistics to external services, such as statsd, stathat, etc.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

Build Status

This project provides a simple "framework" for profiling request / response times, and sending the data to another service. It includes a base class Rack::RequestProfiler for handling the logic of wrapping and timing the request / response cycle in a rack app.

By default, the Rack::RequestProfiler middleware does not do anything with the profiling data. Instead, this logic must be implemented by subclasses by defining the handle_results instance method. For example, you might send profiling data to an external web service (stathat, papertrail, loggly, etc), statsd, write to a logfile on disk, put it in a persistent store like redis or mongo, or really anything else your heart desires.

This project currently provides profiler middlewares for stathat and statsd. If you'd like to contribute a profiler middleware, pull requests are welcome.

Installation

gem install rack-request_profiler

Usage

Simply include one of the profiler middlewares into the middleware stack in any rack-compatible application like so:

$statsd = Statsd.new('localhost')
use Rack::Profilers::Statsd, $statsd, :ignore_path => /^\/assets/

Be default, we match URL's that look like BSON ids. You can over-ride this regular expression like this:

Rack::Utils::UrlStripper.id_pattern = /some_other_pattern/

Profilers

  • Statsd - Uses the statsd ruby client to send data to statsd / graphite.
  • Stathat - Uses the em-stathat gem to send data to stathat asynchronously via eventmachine.