Method: FFWD::Statistics::Collector#initialize
- Defined in:
- lib/ffwd/statistics/collector.rb
#initialize(emitter, channel, system, opts) ⇒ Collector
Initialize the statistics collector.
emitter - The emitter used to dispatch metrics for all reporters and statistics collectors. channel - A side-channel used by the SystemStatistics component to report information about the system. Messages sent on this channel help Core decide if it should seppuku.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/ffwd/statistics/collector.rb', line 46 def initialize emitter, channel, system, opts @emitter = emitter @channel = channel @system = system @period = opts[:period] @prefix = opts[:prefix] = opts[:tags] @attributes = opts[:attributes] @reporters = {} @timer = nil starting do @last = Time.now @timer = EM::PeriodicTimer.new @period do now = Time.now generate! @last, now @last = now end log.info "Started #{opts.inspect}" end stopping do if @timer @timer.cancel @timer = nil end log.info "Stopped" end end |