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

parser_json: use JSON as fallback parser instead of Yajl for performance #4813

Merged
merged 1 commit into from
Feb 3, 2025
Merged
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
4 changes: 2 additions & 2 deletions lib/fluent/plugin/parser_json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ def configure_json_parser(name)
when :oj
return [Oj.method(:load), Oj::ParseError] if Fluent::OjOptions.available?

log&.info "Oj is not installed, and failing back to Yajl for json parser"
configure_json_parser(:yajl)
log&.info "Oj is not installed, and failing back to JSON for json parser"
configure_json_parser(:json)
when :json then [JSON.method(:load), JSON::ParserError]
when :yajl then [Yajl.method(:load), Yajl::ParseError]
else
Expand Down
4 changes: 2 additions & 2 deletions test/plugin/test_parser_json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ def test_fall_back_oj_to_yajl_if_oj_not_available

result = @parser.instance.configure_json_parser(:oj)

assert_equal [Yajl.method(:load), Yajl::ParseError], result
assert_equal [JSON.method(:load), JSON::ParserError], result
logs = @parser.logs.collect do |log|
log.gsub(/\A\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} [-+]\d{4} /, "")
end
assert_equal(
["[info]: Oj is not installed, and failing back to Yajl for json parser\n"],
["[info]: Oj is not installed, and failing back to JSON for json parser\n"],
logs
)
end
Expand Down