Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't chomp formatted messages. Fixes #142 #144

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/fluent/plugin/kinesis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def data_formatter_create(conf)
unless fluentd_v0_12?
record = inject_values_to_record(tag, time, record)
end
compressor.call(formatter.format(tag, time, record).chomp.b)
compressor.call(formatter.format(tag, time, record).b)
}
else
->(tag, time, record) {
Expand Down
2 changes: 1 addition & 1 deletion test/plugin/test_kinesis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def test_time_key
record = {"a"=>"foo"}
time = event_time("2011-01-02 13:14:15.161718190 UTC")
if fluentd_v0_12?
d.expect_format([record.merge("time"=>"2011-01-02T13:14:15Z").to_json.b].to_msgpack)
d.expect_format(["#{record.merge("time"=>"2011-01-02T13:14:15Z").to_json}\n".b].to_msgpack)
driver_run(d, [record], time: time)
else
driver_run(d, [record], time: time)
Expand Down
10 changes: 5 additions & 5 deletions test/plugin/test_out_kinesis_firehose.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ def test_region
end

data(
'json' => ['json', "{\"a\":1,\"b\":2}\n"],
'ltsv' => ['ltsv', "a:1\tb:2\n"],
'json' => ['json', "{\"a\":1,\"b\":2}"],
'ltsv' => ['ltsv', "a:1\tb:2"],
)
def test_format(data)
formatter, expected = data
d = create_driver(default_config + "format #{formatter}")
driver_run(d, [{"a"=>1,"b"=>2}])
assert_equal expected, @server.records.first
assert_equal ("#{expected}\n" + "\n").b, @server.records.first
end

data(
Expand All @@ -94,7 +94,7 @@ def test_format_without_append_new_line(data)
formatter, expected = data
d = create_driver(default_config + "format #{formatter}\nappend_new_line false")
driver_run(d, [{"a"=>1,"b"=>2}])
assert_equal expected, @server.records.first
assert_equal "#{expected}\n".b, @server.records.first
end

def test_data_key
Expand Down Expand Up @@ -178,7 +178,7 @@ def test_multibyte_input
record = {"a" => "てすと"}
driver_run(d, [record])
assert_equal 0, d.instance.log.out.logs.size
assert_equal record.to_json.b + "\n", @server.records.first
assert_equal ("#{record.to_json}\n" + "\n").b, @server.records.first
end

def test_record_count
Expand Down
4 changes: 2 additions & 2 deletions test/plugin/test_out_kinesis_streams.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def test_format(data)
formatter, expected = data
d = create_driver(default_config + "format #{formatter}")
driver_run(d, [{"a"=>1,"b"=>2}])
assert_equal expected, @server.records.first
assert_equal expected + "\n", @server.records.first
end

def test_partition_key_not_found
Expand Down Expand Up @@ -156,7 +156,7 @@ def test_multibyte_input
record = {"a" => "てすと"}
driver_run(d, [record])
assert_equal 0, d.instance.log.out.logs.size
assert_equal record.to_json.b, @server.records.first
assert_equal (record.to_json + "\n").b, @server.records.first
end

def test_record_count
Expand Down
4 changes: 2 additions & 2 deletions test/plugin/test_out_kinesis_streams_aggregated.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def test_format(data)
formatter, expected = data
d = create_driver(default_config + "format #{formatter}")
driver_run(d, [{"a"=>1,"b"=>2}])
assert_equal expected, @server.records.first
assert_equal (expected + "\n").b, @server.records.first
end

def test_data_key
Expand Down Expand Up @@ -177,7 +177,7 @@ def test_multibyte_input
record = {"a" => "てすと"}
driver_run(d, [record])
assert_equal 0, d.instance.log.out.logs.size
assert_equal record.to_json.b, @server.records.first
assert_equal (record.to_json + "\n").b, @server.records.first
end

data(
Expand Down