lib/fluent/plugin/formatter_protobuf.rb in fluent-plugin-formatter-protobuf-0.3.0 vs lib/fluent/plugin/formatter_protobuf.rb in fluent-plugin-formatter-protobuf-0.4.0

- old
+ new

@@ -39,10 +39,17 @@ default: false, desc: <<~DESC Serializes record from canonical proto3 JSON mapping (https://developers.google.com/protocol-buffers/docs/proto3#json) into binary' DESC + config_param :ignore_unknown_fields, + :bool, + default: true, + desc: <<~DESC + Ignore unknown fields when decoding JSON. This parameter is only used if `decode_json` is `true` + DESC + config_param :format_field, :string, default: '', desc: <<~DESC When defined, the plugin will only serialise the record in the given field rather than the whole record. @@ -87,10 +94,11 @@ def format(_tag, _time, record) format_record = @format_field == '' ? record : record[@format_field] protobuf_msg = if @decode_json - @protobuf_class.decode_json(Oj.dump(format_record)) + @protobuf_class.decode_json(Oj.dump(format_record), + { ignore_unknown_fields: @ignore_unknown_fields }) else @protobuf_class.new(format_record) end @protobuf_class.encode(protobuf_msg) end