class Fluent::LatencyOutput
Attributes
latency[R]
Public Class Methods
new()
click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_latency.rb, line 20 def initialize super @latency = [] end
Public Instance Methods
configure(conf)
click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_latency.rb, line 25 def configure(conf) super end
emit(tag, es, chain)
click to toggle source
# File lib/fluent/plugin/out_latency.rb, line 29 def emit(tag, es, chain) current = Time.now.to_f es.each do |time, record| @latency << (current - time) end chain.next end
flush_emit()
click to toggle source
# File lib/fluent/plugin/out_latency.rb, line 59 def flush_emit latency, @latency = @latency, [] num = latency.size max = num == 0 ? 0 : latency.max avg = num == 0 ? 0 : latency.map(&:to_f).inject(:+) / num.to_f message = {"max" => max, "avg" => avg, "num" => num} router.emit(@tag, Engine.now, message) end
run()
click to toggle source
# File lib/fluent/plugin/out_latency.rb, line 48 def run @last_checked ||= Engine.now while (sleep 0.5) now = Engine.now if now - @last_checked >= @interval flush_emit @last_checked = now end end end
shutdown()
click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_latency.rb, line 42 def shutdown super @thread.terminate @thread.join end
start()
click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_latency.rb, line 37 def start super @thread = Thread.new(&method(:run)) end