lib/fluent/plugin/out_flowcounter.rb in fluent-plugin-flowcounter-0.4.1 vs lib/fluent/plugin/out_flowcounter.rb in fluent-plugin-flowcounter-0.4.2

- old
+ new

@@ -18,10 +18,11 @@ config_param :output_style, :string, default: 'joined' config_param :tag, :string, default: 'flowcount' config_param :input_tag_remove_prefix, :string, default: nil config_param :count_keys, :string, default: nil config_param :delimiter, :string, default: '_' + config_param :delete_idle, :bool, default: false include Fluent::Mixin::ConfigPlaceholders attr_accessor :counts attr_accessor :last_checked @@ -124,15 +125,17 @@ } counts.update(rates) end def flush(step) - flushed,@counts = @counts,count_initialized(@counts.keys) + keys = delete_idle ? nil : @counts.keys + flushed,@counts = @counts,count_initialized(keys) generate_output(flushed, step) end def tagged_flush(step) - flushed,@counts = @counts,count_initialized(@counts.keys) + keys = delete_idle ? nil : @counts.keys + flushed,@counts = @counts,count_initialized(keys) names = flushed.keys.select {|x| x.end_with?(delimiter + 'count')}.map {|x| x.chomp(delimiter + 'count')} names.map {|name| counts = { 'count' => flushed[name + delimiter + 'count'], }