tracing icon indicating copy to clipboard operation
tracing copied to clipboard

tracing-subscriber: refactor timings

Open joshka opened this issue 1 year ago • 2 comments

Motivation

This makes the fmt::Subscriber code a bit simpler, and preps the Timing type for lifting elsewhere (e.g. to be made public and part of a timing layer instead of hidden within this Subscriber) (see https://github.com/tokio-rs/tracing/issues/2946)

Solution

This commit refactors the Timings struct to use Duration instead of u64 to store the idle and busy times of a span, and moves the logic to update the timings to the Timings struct itself. This commit also introduces a display method to the Timings struct that returns the idle and busy times as HumanReadableDuration instances (renamed from TimingDisplay).

Replaces: https://github.com/tokio-rs/tracing/pull/2944

joshka avatar Jul 23 '24 07:07 joshka

What about renaming this to SpanTimings instead of Timings? It's currently private, so this isn't breaking.

Side note: My personal style would be to move this to its own small module, as it's a neatly self contained piece that doesn't depend on other parts of the library. I like using modules to reduce the cognitive load of reading larger source files, but I don't know how this squares with the library maintainers, and everyone has different preferences on what sizes matter.

joshka avatar Jul 23 '24 21:07 joshka

Hey maintainers, any thoughts about moving forward with this?

joshka avatar Feb 16 '25 06:02 joshka