Class: RequestLog::Objects
- Inherits:
-
Object
- Object
- RequestLog::Objects
- Includes:
- Mongrel::HttpHandlerPlugin
- Defined in:
- lib/mongrel/debug.rb
Overview
stolen from Robert Klemme
Instance Attribute Summary
Attributes included from Mongrel::HttpHandlerPlugin
#listener, #options, #request_notify
Instance Method Summary collapse
Methods included from Mongrel::HttpHandlerPlugin
#initialize, #request_begins, #request_progress
Instance Method Details
#process(request, response) ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/mongrel/debug.rb', line 121 def process(request,response) begin stats = Hash.new(0) lengths = {} begin ObjectSpace.each_object do |o| begin if o.respond_to? :length len = o.length lengths[o.class] ||= Mongrel::Stats.new(o.class) lengths[o.class].sample(len) end rescue Object end stats[o.class] += 1 end rescue Object # Ignore since ObjectSpace might not be loaded on JRuby end stats.sort {|(k1,v1),(k2,v2)| v2 <=> v1}.each do |k,v| if $last_stat delta = v - $last_stat[k] if v > 10 and delta != 0 if lengths[k] $objects_out.printf "%d,%s,%d,%d,%d,%f,%f,%f\n", $run_count, k, $last_stat[k], v, delta,lengths[k].mean,lengths[k].sd,lengths[k].max else $objects_out.printf "%d,%s,%d,%d,%d,,,\n", $run_count, k, $last_stat[k], v, delta end end end end $run_count += 1 $last_stat = stats rescue Object STDERR.puts "object.log ERROR: #$!" end end |