Non-spawned tasks (tracing futures) #6011
-
That might sound stupid, and maybe there's already something for that. Would it be possible to have tasks, that are not spawned onto a runtime? I've discovered tokio console, and I absolutely love it. The only thing that I'm missing is the ability to track arbitrary futures that are not directly spawned on the runtime. Especially when working with generic code, it's not always desirable to add a Would it be reasonable to add something like a |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Looking at the code, it seems like the only thing that would be required would be to call |
Beta Was this translation helpful? Give feedback.
-
Currently, We could also associate user spans within a task span with the task span in the console, so you could see which task a chain of child futures were executing inside of. |
Beta Was this translation helpful? Give feedback.
I don't think adding duplicates of the task span to arbitrary futures is as useful as enhancing the console to display arbitrary traces. This specific span is intended to be used for tracking tasks spawned on the runtime. Wrapping other futures in a task span would incorrectly indicate that they are also spawned as tasks, when they are not.
Furthermore, providing a general purpose utility for instrumenting futures with spans is not
tokio::task
's responsibility.tracing
itself provides a much more full-featured API for constructing spans to instrument arbitrary futures. I think enhancing the console's ability to display user-definedtracing
instrumentation is a better approach.With that s…