From da965b15799a9b60d6a8808dcde1888faec96f0c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 14 Jul 2022 19:46:14 +0100 Subject: [PATCH 1/2] doc: remove misleading doc There's no automated propagation of subscrbibers between spans, you have to do this manually. https://discord.com/channels/500028886025895936/997201342596657232/997210656677830778 --- tracing/src/collect.rs | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/tracing/src/collect.rs b/tracing/src/collect.rs index 79a6832d84..3616c4b350 100644 --- a/tracing/src/collect.rs +++ b/tracing/src/collect.rs @@ -5,16 +5,8 @@ pub use tracing_core::collect::*; #[cfg_attr(docsrs, doc(cfg(feature = "std")))] pub use tracing_core::dispatch::DefaultGuard; -/// Sets this collector as the default for the duration of a closure. -/// -/// The default collector is used when creating a new [`Span`] or -/// [`Event`], _if no span is currently executing_. If a span is currently -/// executing, new spans or events are dispatched to the collector that -/// tagged that span, instead. -/// -/// [`Span`]: super::span::Span -/// [`Collect`]: super::collect::Collect -/// [`Event`]: tracing_core::Event +/// Sets this collector as the default for the current thread for the duration +/// of a closure. #[cfg(feature = "std")] #[cfg_attr(docsrs, doc(cfg(feature = "std")))] pub fn with_default(collector: C, f: impl FnOnce() -> T) -> T @@ -43,16 +35,8 @@ where crate::dispatch::set_global_default(crate::Dispatch::new(collector)) } -/// Sets the collector as the default for the duration of the lifetime of the -/// returned [`DefaultGuard`] -/// -/// The default collector is used when creating a new [`Span`] or -/// [`Event`], _if no span is currently executing_. If a span is currently -/// executing, new spans or events are dispatched to the collector that -/// tagged that span, instead. -/// -/// [`Span`]: super::span::Span -/// [`Event`]: tracing_core::Event +/// Sets the collector as the default for the current thread for the duration of +/// the lifetime of the returned [`DefaultGuard`]. #[cfg(feature = "std")] #[cfg_attr(docsrs, doc(cfg(feature = "std")))] #[must_use = "Dropping the guard unregisters the collector."] From 05a8a9bebe20e49ee6ce03b6f0455ceb0c732a49 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Thu, 14 Jul 2022 12:35:58 -0700 Subject: [PATCH 2/2] Apply suggestions from code review --- tracing/src/collect.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tracing/src/collect.rs b/tracing/src/collect.rs index 3616c4b350..5630037f63 100644 --- a/tracing/src/collect.rs +++ b/tracing/src/collect.rs @@ -7,6 +7,12 @@ pub use tracing_core::dispatch::DefaultGuard; /// Sets this collector as the default for the current thread for the duration /// of a closure. +/// +/// The default collector is used when creating a new [`Span`] or +/// [`Event`]. +/// +/// [`Span`]: super::span::Span +/// [`Event`]: tracing_core::Event #[cfg(feature = "std")] #[cfg_attr(docsrs, doc(cfg(feature = "std")))] pub fn with_default(collector: C, f: impl FnOnce() -> T) -> T @@ -37,6 +43,12 @@ where /// Sets the collector as the default for the current thread for the duration of /// the lifetime of the returned [`DefaultGuard`]. +/// +/// The default collector is used when creating a new [`Span`] or +/// [`Event`]. +/// +/// [`Span`]: super::span::Span +/// [`Event`]: tracing_core::Event #[cfg(feature = "std")] #[cfg_attr(docsrs, doc(cfg(feature = "std")))] #[must_use = "Dropping the guard unregisters the collector."]