Skip to content
This repository has been archived by the owner on Oct 30, 2021. It is now read-only.

cpetersen/rack-couchlogger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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 © 2009 Christopher Petersen. See LICENSE for details.

About

Rack middleware to log request info to CouchDB

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages