Class: RequestLog::Objects

Class | RequestLog::Objects
In: | lib/mongrel/debug.rb lib/mongrel/debug.rb
Parent: | GemPlugin::Plugin"/handlers"

stolen from Robert Klemme

### Methods

process process

### Included Modules

Mongrel::HttpHandlerPlugin Mongrel::HttpHandlerPlugin

### Public Instance methods

process(request,response)

[Source]

         # File lib/mongrel/debug.rb, line 121
    121:     def process(request,response)
    122:       begin
    123:         stats = Hash.new(0)
    124:         lengths = {}
    125:         begin
    126:           ObjectSpace.each_object do |o|
    127:             begin
    128:               if o.respond_to? :length
    129:                 len = o.length
    130:                 lengths[o.class] ||= Mongrel::Stats.new(o.class)
    131:                 lengths[o.class].sample(len)
    132:               end
    133:             rescue Object
    134:             end
    135:
    136:             stats[o.class] += 1
    137:           end
    138:         rescue Object # Ignore since ObjectSpace might not be loaded on JRuby
    139:         end
    140:
    141:         stats.sort {|(k1,v1),(k2,v2)| v2 <=> v1}.each do |k,v|
    142:           if $last_stat
    143:             delta = v - $last_stat[k]
    144:             if v > 10 and delta != 0
    145:               if lengths[k]
    146:                 $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
    147:               else
    148:                 $objects_out.printf "%d,%s,%d,%d,%d,,,\n", $run_count, k, $last_stat[k], v, delta
    149:               end
    150:             end
    151:           end
    152:         end
    153:
    154:         $run_count += 1
    155:         $last_stat = stats
    156:       rescue Object
    157:         STDERR.puts "object.log ERROR: #$!"
    158:       end
    159:     end

process(request,response)

[Source]

         # File lib/mongrel/debug.rb, line 121
    121:     def process(request,response)
    122:       begin
    123:         stats = Hash.new(0)
    124:         lengths = {}
    125:         begin
    126:           ObjectSpace.each_object do |o|
    127:             begin
    128:               if o.respond_to? :length
    129:                 len = o.length
    130:                 lengths[o.class] ||= Mongrel::Stats.new(o.class)
    131:                 lengths[o.class].sample(len)
    132:               end
    133:             rescue Object
    134:             end
    135:
    136:             stats[o.class] += 1
    137:           end
    138:         rescue Object # Ignore since ObjectSpace might not be loaded on JRuby
    139:         end
    140:
    141:         stats.sort {|(k1,v1),(k2,v2)| v2 <=> v1}.each do |k,v|
    142:           if $last_stat
    143:             delta = v - $last_stat[k]
    144:             if v > 10 and delta != 0
    145:               if lengths[k]
    146:                 $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
    147:               else
    148:                 $objects_out.printf "%d,%s,%d,%d,%d,,,\n", $run_count, k, $last_stat[k], v, delta
    149:               end
    150:             end
    151:           end
    152:         end
    153:
    154:         $run_count += 1
    155:         $last_stat = stats
    156:       rescue Object
    157:         STDERR.puts "object.log ERROR: #$!"
    158:       end
    159:     end

[Validate]