logparser icon indicating copy to clipboard operation
logparser copied to clipboard

Accidentally merging multiple JSON logs into one

Open bnonce opened this issue 4 months ago • 0 comments

We've a case where coroot-node-agent (logparser) accidentally merges multiple json logs into one but we expect to receive them one-by-one. Output:

{"context":"App:TypeOrmTransactionContext","level":"debug","timestamp":"2024-02-21T12:35:48.232Z","ms":"+1ms","span_id":"2aa1bcfe9bc837f2","trace_id":"1167fdf089bce248aa87fddee93eedff","msg":"..."}
{"context":"App:TypeOrmTransactionContext","level":"debug","timestamp":"2024-02-21T12:35:48.239Z","ms":"+7ms","span_id":"2aa1bcfe9bc837f2","trace_id":"1167fdf089bce248aa87fddee93eedff","msg":"..."}
{"context":"App:TypeOrmTransactionContext","level":"debug","timestamp":"2024-02-21T12:35:48.239Z","ms":"+0ms","span_id":"2aa1bcfe9bc837f2","trace_id":"1167fdf089bce248aa87fddee93eedff","msg":"..."}

We fixed this issue by changing the order of the json fields to get the timestamp first (to pass this condition https://github.com/coroot/logparser/blob/main/multiline.go#L123). But it would be nice to detect json correctly and not depend on the order of the fields.

bnonce avatar Feb 21 '24 14:02 bnonce