Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tracing/src/instrument.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ pub trait WithSubscriber: Sized {
}
}

impl<T: Sized> WithSubscriber for T {}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bound here is copied from tracing-futures. It might be worth adding a Future bound to avoid polluting autocompletes too much though?

Copy link
Member

@hawkw hawkw Jun 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tracing-futures version does not have a Future bound because it also allows wrapping types implementing other traits, such as Stream, with a subscriber. However, tracing's version only provides implementations for Future, because tracing depends only on the standard library, not the futures crate. So, it should be fine to restrict the blanket impl to T: Future, here.

However, when the Stream trait eventually does make it into std, we'll probably want to add a Stream impl for WithSubscriber<T: Stream>, as well. Then, we'll have to make the blanket impl more general. Technically, I think this is a breaking change, as it could break user WithSubscriber impls for types that don't implement Future. To protect against that, I think we would need to seal the trait so that downstream code can't add WithSubscriber impls. Then, it would be fine to add a Future bound on the blanket impl, for now.


pin_project! {
/// A future that has been instrumented with a `tracing` subscriber.
#[derive(Clone, Debug)]
Expand Down