Rack middleware to log request info to CouchDB
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE
README.rdoc
config.ru
couch_logger.rb

README.rdoc

rack-couchlogger

rack-couchlogger is Rack middleware that stores the environment for every incoming request, as well as the duration of the request and request time in CouchDB. It also provides basic ability to query that data. Your config.ru should looks something like:

require 'rubygems'
require 'couch_logger'

use Rack::CouchLogger
run lambda { [200, {"Content-Type" => "text/plain"}, ["Hello world!"]] }

You can query your log by using the following methods:

Log.by_created_at

returns all log events by the date/time they were created.

Log.by_path_info_times(:raw => true, :reduce => true, :group => true)["rows"].each do |r| 
  puts "#{r["key"]} takes #{r["value"]} seconds on average"
end

returns all the paths that have been requested and their average duration:

/ takes 0.00101852675953079 seconds on average
/favicon.ico takes 0.000547599665421724 seconds on average

Source

github.com/cpetersen/rack-couchlogger

Copyright

Copyright © 2009 Christopher Petersen. See LICENSE for details.