davidbarsky / tracing-tree

Apache License 2.0
123 stars 31 forks source link

Better handling for multiple functions running async #50

Closed BBaoVanC closed 1 year ago

BBaoVanC commented 1 year ago

If I make a simple webserver with axum that just sleeps for 3 seconds before sending a response, then it works great with just one request at a time:

log{}
  0ms  INFO Will sleep
  3001ms  INFO Done sleeping

log{}
  0ms  INFO Will sleep
  3002ms  INFO Done sleeping

However, if I make three requests simultaneously, then it gets confusing:

log{}
  0ms  INFO Will sleep
log{}
  0ms  INFO Will sleep
log{}
  0ms  INFO Will sleep
  3001ms  INFO Done sleeping

  3001ms  INFO Done sleeping

  3001ms  INFO Done sleeping

It could be complicated, but it would be very useful to make sure that each message is under the correct tree visually, so it looks more like the first example, even if multiple requests were made simultaneously. That was the expectation I had when I tried this library.

davidbarsky commented 1 year ago

Sorry for the delayed response. I think to suppose this use-case, I'll need to change tracing-tree to dynamically re-render in the terminal, and while that is possible, it's more work than I'm willing to put into this crate specifically. I think that effort would be better spent improving https://github.com/tokio-rs/console to consume events from outside Tokio.