lib/tunemygc/snapshotter.rb in tunemygc-1.0.2 vs lib/tunemygc/snapshotter.rb in tunemygc-1.0.3

- old
+ new

@@ -2,16 +2,19 @@ require 'thread' module TuneMyGc class Snapshotter + UNITS_OF_WORK = /REQUEST_PROCESSING_STARTED|REQUEST_PROCESSING_ENDED/ MAX_SAMPLES = 1000 attr_reader :buffer + attr_accessor :unit_of_work def initialize(buf = Queue.new) @buffer = buf + @unit_of_work = false end def take(stage, timestamp = nil, meta = nil) _buffer([(timestamp || TuneMyGc.walltime), TuneMyGc.peak_rss, TuneMyGc.current_rss, stage, GC.stat, GC.latest_gc_info, meta]) end @@ -38,9 +41,10 @@ end private def _buffer(snapshot) if size < MAX_SAMPLES + self.unit_of_work = true if snapshot[3] =~ UNITS_OF_WORK @buffer << snapshot else TuneMyGc.log "Discarding snapshot #{snapshot.inspect} (max samples threshold of #{MAX_SAMPLES} reached)" end end \ No newline at end of file