tokio-rs / tracing

Application level tracing for Rust.
https://tracing.rs
MIT License
5.19k stars 677 forks source link

Should crate documentation call out that non-blocking writers are lossy by default? #2865

Open f1recracker opened 6 months ago

f1recracker commented 6 months ago

Feature Request

Crates

tracing-appender

Motivation

By default, non blocking appenders are lossy. Should the crate documentation call this out explicitly?

The crate docs are enough to get a working example, but it misses an important caveat. Silently, losing logs in a production environment is hard to diagnose, and should not be a default.

Further programs using asynchronous logging are probably fast enough where they might be silently running into this scenario.

Proposal

Add another Note beside the current note for WorkerGuard.

Note: non_blocking appenders are lossy by default and will drop events once internal buffers are filled. See non_blocking module for more details.

Alternatives

lossy may be disabled by default, but this might cause regression in environments where log loss actually occurs.

hawkw commented 6 months ago

Yeah, I think it would be good to document this behavior more clearly. I'd happily merge a PR!

f1recracker commented 6 months ago

Thank you! I'd happy to contribute to the project too - I just raised a PR!