emit-rs / emit

Developer-first diagnostics for Rust applications
Apache License 2.0
123 stars 2 forks source link

Allow batcher to block on a full queue instead of truncating #80

Closed KodrAus closed 1 month ago

KodrAus commented 1 month ago

Closes #68

The default background batching implementation will truncate all unprocessed events if it fills up. This is to prevent logging from blocking up the works, and based on the assumption that newer events are more important than older ones.

This isn't suitable for using the batcher for auditing or proxying use-cases so this PR introduces a function that emitters can use to block waiting for the current batch to be flushed if it's full instead of truncating. If this times out instead of adding the event then it's returned to the caller, who can then discard it or issue a destructive non-blocking send instead.