Open
Description
In near/nearcore#4033 (comment), I've noticed that tracing reports spurious idle time. That is, my code looks like this:
{
let _s = tracing::info_span("blurb").entered();
do_important_blockchain_stuff()
}
and the logs look like this:
blurb: close time.busy=18.2ms time.idle=1.15µs
Note how the idle time is non-zero.
The reason for that is that tracing emits separate events for span exiting and span closing (and for span creation and exiting). In both callbacs, tracing calls Instant::now and the diff between the two (which is overhead of the tracing itself) gets counted as idle time.
I think the fix here is to allow atomically exit and close span, so that only one time measurement can be taken. Not sure what's the appropriate abstraction to add this API.