Skip to content

Commit

Permalink
in_sample: duplicate record to support destructive change
Browse files Browse the repository at this point in the history
When in_sample plugin is used with filter parser which uses
remove_key_name_field, it raises the following error repeatedly.

  #0 dump an error event: error_class=ArgumentError error="message
  does not exist"

This kind of error occurs when key_name and remove_key_name_field
removes key from record with destructive change in filter parser
affects generated sample data.

ref. #4575

Signed-off-by: Kentaro Hayashi <hayashi@clear-code.com>
  • Loading branch information
kenhys committed Aug 14, 2024
1 parent 5618dd0 commit 76876f1
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/fluent/plugin/in_sample.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,13 @@ def emit(num)
end

def generate
d = @sample[@sample_index]
d = @sample[@sample_index].dup
unless d
@sample_index = 0
d = @sample[@sample_index]
d = @sample[@sample_index].dup
end
@sample_index += 1
if @auto_increment_key
d = d.dup
d[@auto_increment_key] = @storage.update(:auto_increment_value){|v| v + 1 }
end
d
Expand Down

0 comments on commit 76876f1

Please sign in to comment.