tokio-rs / tracing

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

tracing-subscriber: count numbers of enters in `Timings` #2944

Open mladedav opened 2 months ago

mladedav commented 2 months ago

Motivation

The timings measurements were done naively in a way where they added busy time in on_exit and idle time in `on_enter. This works only if the spans are not entered multiple times. For example if a span is:

entered
wait 1 second
entered
exited
exited

The timing would be about 1 second of idle time and no busy time.

Solution

Count the relative number of enters and exits and only increment the timers on top-level enters and exits.