logstash-codec-json
logstash-codec-json copied to clipboard
Refactor: reduce parse error logging level
before https://github.com/logstash-plugins/logstash-codec-json/pull/37 there were 2 error handlers:
rescue LogStash::Json::ParserError => e
@logger.info("JSON parse failure. Falling back to plain-text", :error => e, :data => json)
yield LogStash::Event.new("message" => json, "tags" => ["_jsonparsefailure"])
rescue StandardError => e
# This should NEVER happen. But hubris has been the cause of many pipeline breaking things
# If something bad should happen we just don't want to crash logstash here.
@logger.warn(
"An unexpected error occurred parsing JSON data",
:data => json,
:message => e.message,
:class => e.class.name,
:backtrace => e.backtrace
)
... this got replaced (in #37) by a single handler that logs at error level and always generates a fallback event:
rescue => e
@logger.error("JSON parse error, original data now in message field", message: e.message, exception: e.class, data: json)
yield parse_json_error_event(json)
the gist of the change here is to "reduce" the logging on parsing errors to a warn
and only log at the error
level when smt unexpected happens ...