Skip to content

Commit

Permalink
filter: Handle enable_size_metrics to add switch for collecting size
Browse files Browse the repository at this point in the history
metrics

Signed-off-by: Hiroshi Hatake <hatake@calyptia.com>
  • Loading branch information
cosmo0920 committed Jul 27, 2021
1 parent 9421a55 commit adf9002
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/fluent/plugin/filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ def initialize
@emit_records = 0
@emit_size = 0
@counter_mutex = Mutex.new
@enable_size_metrics = false
end

def configure(conf)
super

@enable_size_metrics = !!system_config.enable_size_metrics
end

def statistics
Expand All @@ -52,7 +59,7 @@ def statistics
def measure_metrics(es)
@counter_mutex.synchronize do
@emit_records += es.size
@emit_size += es.to_msgpack_stream.bytesize
@emit_size += es.to_msgpack_stream.bytesize if @enable_size_metrics
end
end

Expand Down

0 comments on commit adf9002

Please sign in to comment.