lib/fluent/plugin/out_latency.rb in fluent-plugin-latency-0.0.2 vs lib/fluent/plugin/out_latency.rb in fluent-plugin-latency-0.0.3

- old
+ new

@@ -1,14 +1,19 @@ module Fluent - class LatencyOutput < Output + class LatencyOutput < MultiOutput Plugin.register_output('latency', self) # To support log_level option implemented by Fluentd v0.10.43 unless method_defined?(:log) define_method("log") { $log } end + # Define `router` method of v0.12 to support v0.10 or earlier + unless method_defined?(:router) + define_method("router") { Fluent::Engine } + end + config_param :tag, :string, :default => 'latency' config_param :interval, :time, :default => 60 attr_reader :latency # for test @@ -55,9 +60,9 @@ 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} - Engine.emit(@tag, Engine.now, message) + router.emit(@tag, Engine.now, message) end end end