News for hackers. Stuff that matters.
Re:Structured Logging with Slog by kusha on Tuesday August 22, 2023 @03:05PM (#37227190)
Oof. We just converted all of our logging to zap[0] to get structured JSON logging for downstream parsing. Wonder how the perf stacks up.

[0]: https://github.com/uber-go/zap

Re:Structured Logging with Slog by tony_cannistra on Tuesday August 22, 2023 @03:44PM (#37227639)
It looks like they've included slog in their performance benchmarks, which show zap as considerably more performant (though I don't really understand the benchmark).
Re:Structured Logging with Slog by llimllib on Tuesday August 22, 2023 @08:32PM (#37230425)
http://bench.zerolog.io/ Is a useful set of benchmarks
Re:Structured Logging with Slog by yencabulator on Wednesday August 23, 2023 @11:28AM (#37237573)
That test puts a lot of stuff through `slog.Any`, while the zap version uses more strongly-typed variants, so I'm not sure it's a fair comparison.

What it comes down to is that zap special cases things like slice-of-int, slice-of-string, slice-of-timestamp, slog doesn't, and the benchmark includes all those special cases. I question whether your typical log statement includes slices. A more fair benchmark would be just scalar types, and zap & slog optimizations there look pretty similar.

https://github.com/uber-go/zap/blob/fd37f1f613a87773fc30f719...

https://github.com/uber-go/zap/blob/fd37f1f613a87773fc30f719...