Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This will utilize a separate thread to write out the spans and events without while letting the main computation to proceed with its business. Additionally, we are buffering the output by lines, thus reducing the frequency of syscalls that can occur when the subscriber is writing out parts of the message. This should mitigate concerns of enabling debug logging as its impact on performance should now be minimal (putting an event structure onto a MPSC queue.) There are still costs associated with logging everything however. Most notably formatting and construction of the `tracing_core::ValueSet`s still occur on the caller side, so if constructing those is expensive, the logging might remain expensive. An example of code sketchy like that (although silly) could be: ``` debug!(message = { std::time::sleep(Duration::from_secs(1)); "hello" }) ``` or for a less silly example: ``` debug!("{}", my_vector.iter().map(|...| { do_expensive_stuff() }).collect::<String>()) ``` These should be considered a bug (alas one that `tracing` does not have any tooling to detect, sadly.) I opted adding a new crate dedicated to observability utilities. From my experience using things like prometheus will eventually result in a variety of utilities being written, so this crate eventually would likely expand in scope... Fixes #6072 (though I haven't made any actual measurements as to what the improvement really is)
- Loading branch information