lib/fluent/plugin/out_metricsense.rb in fluent-plugin-metricsense-0.3.0 vs lib/fluent/plugin/out_metricsense.rb in fluent-plugin-metricsense-0.3.1

- old
+ new

@@ -252,19 +252,10 @@ def mode UpdateMode::AVERAGE end end - class SegmentedTotalUpdater < AddUpdater - def initialize(original_mode) - super() - @mode = original_mode - end - - attr_reader :mode - end - AggregationKey = Struct.new(:tag, :time, :seg_val, :seg_key) def write(chunk) simple_counters = {} segmented_counters = {} @@ -284,32 +275,21 @@ updater = CountUpdater else # default is AddUpdater updater = AddUpdater end - if segments.empty? - # simple values - ak = AggregationKey.new(tag, time, nil, nil) - (simple_counters[ak] ||= updater.new).add(value) - else - # segmented values - segments.each_pair {|seg_key,seg_val| - ak = AggregationKey.new(tag, time, seg_val, seg_key) - (segmented_counters[ak] ||= updater.new).add(value) - } - end - } + # simple values + ak = AggregationKey.new(tag, time, nil, nil) + (simple_counters[ak] ||= updater.new).add(value) - # calculate total value of segmented values - segmented_totals = {} - segmented_counters.each_pair {|ak,up| - ak = AggregationKey.new(ak.tag, ak.time, nil, nil) - (segmented_totals[ak] ||= SegmentedTotalUpdater.new(up.mode)).add(up.value) + # segmented values + segments.each_pair {|seg_key,seg_val| + ak = AggregationKey.new(tag, time, seg_val, seg_key) + (segmented_counters[ak] ||= updater.new).add(value) + } } - # simple_counters have higher priority than segmented_totals - counters = segmented_totals - counters.merge!(segmented_counters) + counters = segmented_counters counters.merge!(simple_counters) data = [] counters.each_pair {|ak,up| data << [ak.tag, ak.time, up.normalized_value(@normalize_factor), ak.seg_key, ak.seg_val, up.mode]