Class: Fluent::Plugin::JsonSizeLimitFilter

Inherits:
Filter
  • Object
show all
Defined in:
lib/fluent/plugin/filter_jsonsizelimit.rb

Instance Method Summary collapse

Instance Method Details

#configure(conf) ⇒ Object



28
29
30
31
# File 'lib/fluent/plugin/filter_jsonsizelimit.rb', line 28

def configure(conf)
  super
  log.debug "Configuring JsonSizeLimitFilter with max_size: #{@max_size} and max_attempts: #{@max_attempts}"
end

#filter(tag, time, record) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/fluent/plugin/filter_jsonsizelimit.rb', line 33

def filter(tag, time, record)
  original_size = record.to_json.bytesize
  begin
    reduce_size(record, @max_size)
  rescue => e
    log.error "Error during size reduction: #{e.message}"
    return record # Return the original record in case of an error
  end
  final_size = record.to_json.bytesize

  log.debug "Reduced record size from #{original_size} to #{final_size} bytes" if original_size != final_size
  record
end