lib/fluent/plugin/out_metricsense.rb in fluent-plugin-metricsense-0.2.7 vs lib/fluent/plugin/out_metricsense.rb in fluent-plugin-metricsense-0.2.8

- old
+ new

@@ -29,10 +29,11 @@ module UpdateMode ADD = 0 MAX = 1 AVERAGE = 2 + COUNT = 3 end class Backend UpdateMode = MetricSenseOutput::UpdateMode include Configurable @@ -45,10 +46,11 @@ end end module Backends backend_dir = "#{File.dirname(__FILE__)}/backends" + require "#{backend_dir}/datadog_backend" require "#{backend_dir}/librato_backend" require "#{backend_dir}/rdb_tsdb_backend" require "#{backend_dir}/stdout_backend" end @@ -147,10 +149,12 @@ case update_mode when "max" update_mode = UpdateMode::MAX when "average" update_mode = UpdateMode::AVERAGE + when "count" + update_mode = UpdateMode::COUNT else # default is add update_mode = UpdateMode::ADD end @@ -198,10 +202,29 @@ def mode UpdateMode::ADD end end + class CountUpdater + def initialize + @value = 0 + end + attr_reader :value + + def normalized_value(n) + @value + end + + def add(value) + @value += 1 + end + + def mode + UpdateMode::ADD + end + end + class MaxUpdater def initialize @value = 0 end attr_reader :value @@ -252,9 +275,11 @@ updater = AddUpdater when UpdateMode::MAX updater = MaxUpdater when UpdateMode::AVERAGE # AVERAGE uses MaxUpdater and calculate average on server-side aggregation updater = AverageUpdater + when UpdateMode::COUNT + updater = CountUpdater else # default is AddUpdater updater = AddUpdater end if segments.empty?