# File lib/fluent/plugin/in_object_space.rb, line 26 def initialize super end
# File lib/fluent/plugin/in_object_space.rb, line 50 def configure(conf) super end
# File lib/fluent/plugin/in_object_space.rb, line 91 def on_timer now = Engine.now array = [] map = {} ObjectSpace.each_object {|obj| klass = obj.class rescue Object if c = map[klass] c.incr! else c = Counter.new(klass, 1) array << c map[klass] = c end } array.sort_by! {|c| -c.count } record = {} array.each_with_index {|c,i| break if i >= @top record[c.name] = c.count } router.emit(@tag, now, record) rescue => e log.error "object space failed to emit", error: e.to_s, error_class: e.class.to_s, tag: @tag, record: Yajl.dump(record) end
# File lib/fluent/plugin/in_object_space.rb, line 67 def run @loop.run rescue log.error "unexpected error", error: $!.to_s log.error_backtrace end
# File lib/fluent/plugin/in_object_space.rb, line 61 def shutdown @loop.watchers.each {|w| w.detach } @loop.stop @thread.join end
# File lib/fluent/plugin/in_object_space.rb, line 54 def start @loop = Coolio::Loop.new @timer = TimerWatcher.new(@emit_interval, true, log, &method(:on_timer)) @loop.attach(@timer) @thread = Thread.new(&method(:run)) end