wilson (owner)

Revisions

gist: 92453 Download_button fork
public
Description:
mongrel_object_track.conf
Public Clone URL: git://gist.github.com/92453.git
Embed All Files: show embed
Ruby #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Original code by Robert Klemme
OUT=open("objects.log","w")
OUT.sync = true
$last_stat = nil
$run_count = 0
 
OUT.puts "run,classname,last,count,delta"
 
class ObjectTrackFilter < Mongrel::HttpHandler
  def process(request,response)
    GC.start # force a collection
    stats = Hash.new(0)
    ObjectSpace.each_object {|o| stats[o.class] += 1}
 
    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
          OUT.printf "%d,%s,%d,%d,%d\n", $run_count, k, $last_stat[k], v, delta
        end
      end
    end
 
    $run_count += 1
    $last_stat = stats
  end
end
 
# add :in_front => true to track all requests
uri "/", :handler => ObjectTrackFilter.new, :in_front => true