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.
Motivation
The timings measurements were done naively in a way where they added
busy
time inon_exit
andidle
time in `on_enter. This works only if the spans are not entered multiple times. For example if a span is: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.