Open joshka opened 4 months ago
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.
Motivation
This makes the
fmt::Subscriber
code a bit simpler, and preps theTiming
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 useDuration
instead ofu64
to store the idle and busy times of a span, and moves the logic to update the timings to theTimings
struct itself. This commit also introduces adisplay
method to theTimings
struct that returns the idle and busy times asHumanReadableDuration
instances (renamed fromTimingDisplay
).Replaces: https://github.com/tokio-rs/tracing/pull/2944