tokio-rs / tracing

Application level tracing for Rust.
https://tracing.rs
MIT License
5.15k stars 673 forks source link

Add trait `StreamInstrument ` #2939

Closed cjwcommuny closed 2 months ago

cjwcommuny commented 2 months ago

Feature Request

Motivation

For Future, tracing has the Instrument trait. But for Stream, tracing doesn't have similar trait to use.

Proposal

Add StreamInstrument trait similar to the current Instrument trait.

mladedav commented 2 months ago

This is already implemented, but tracing does not depend on futures so you'll have to use tracing-futures with the futures-03 feature.

Then it should work out of the box the same way as with Future, you just call instrument on your Stream and then use the resulting object as if it was the original.