Skip to content

Commit

Permalink
fix: warn instead of failing for json log line parse error (#1336)
Browse files Browse the repository at this point in the history
## Description:
Occassionally, we hit a race condition between the `LogsAggregator`
writing a log line while `service logs` is reading and streaming log
files. This results in a half written json log line being read while
streaming logs and a parsing error to occur. Instead of failing
immediately, this PR logs a `Warn` instead and continues to read the log
file.


## Is this change user facing?
YES
  • Loading branch information
tedim52 authored Sep 20, 2023
1 parent b8d5816 commit 44b2820
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ func (strategy *PerWeekStreamLogsStrategy) sendJsonLogLine(
// First decode the line
var jsonLog JsonLog
if err := json.Unmarshal([]byte(jsonLogLineStr), &jsonLog); err != nil {
return stacktrace.Propagate(err, "An error occurred parsing the json log string: %v\n", jsonLogLineStr)
logrus.Warnf("An error occurred parsing the json log string: %v. Skipping sending this log line.", jsonLogLineStr)
return nil
}

// Then extract the actual log message using the "log" field
Expand Down

0 comments on commit 44b2820

Please sign in to comment.