subscriber: move timing into separate subscriber layer
Moves the Timing logic out from fmt::Subcriber into its own layer.
Motivation
This allows for the timing subscriber logic to be composed and used by any subscriber rather than just users of the fmt subscriber. I'd like this info to be available as part of some ideas for a new Ratatui tracing layer I'm thinking about.
Solution
A new subscriber (TimingSubscriber) that stores Timing in the span extensions Updated the on_close logic in fmt::Subsciber to use this and removed all the code that otherwise dealt with timing.
The expectation is that this subscriber would be composed when there's need to record any timing data.
TODO: work out how to properly configure the fmt subscriber to use the timing subscriber as a layer (or otherwise make it easy to compose this layer)
Questions:
- is this a good idea?
- what should be the backwards compat story for this?
- should this have a quanta implementation instead of Instant::now, and should that be feature flagged, or just defaulted (ping @tobz for some advice)
Fixes: https://github.com/tokio-rs/tracing/issues/2946 Replaces: https://github.com/tokio-rs/tracing/pull/3038
Added an example which uses this:
tracing_subscriber::registry()
.with(tracing_subscriber::fmt::timing::TimingSubscriber::default())
.with(tracing_subscriber::FmtSubscriber::new().with_span_events(FmtSpan::FULL))
.init();
Hey maintainers this is an alternative to #3038 - are either of these reasonable changes to make?