jonhoo / tracing-timing

Inter-event timing metrics on top of tracing.
113 stars 11 forks source link

Track span timing in addition to inter-event timing #8

Closed david-mcgillicuddy-moixa closed 3 years ago

david-mcgillicuddy-moixa commented 5 years ago

Hi, I might be misunderstanding how this library works but it looks to me like spans are only tracked in order to label their events. I would like to be able to track the spans themselves, so it can be used with e.g. the #[instrument] macro.

It's certainly possible to make a span wrapper that emits an event on start and end but it seems a bit superfluous. Currently my proof of concept was just https://gist.github.com/david-mcgillicuddy-moixa/e925cd78d48a8c3324414ee492532b14

jonhoo commented 5 years ago

So, tracing-timing aims to give you information about time spent in various parts of a "family" of spans. For example, if each request is given its own span, but those spans share a name, then you'll get aggregate states for the time distributions of the events within those spans collectively.

It sounds like what you're looking for is a histogram of the total time spent in each span, is that right? If so, I think the way we'd do that is to add a line near https://github.com/jonhoo/tracing-timing/blob/157833af61162a42e782d9b1e55eb07d7da973a0/src/lib.rs#L616 which takes the current time, subtracts it from the span's start time, which you'd record in here: https://github.com/jonhoo/tracing-timing/blob/157833af61162a42e782d9b1e55eb07d7da973a0/src/lib.rs#L523 You'd then write some code that's essentially a simplified version of fn time to record an extra "full time" event.

bbigras commented 4 years ago

Any progress on this?

akshayknarayan commented 3 years ago

I think span close events (#12) addresses this.

david-mcgillicuddy-moixa commented 3 years ago

Yup, looks like it does thanks.