From a927607fdfebb225025b54d14d5d242f88f49a5d Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Fri, 22 Oct 2021 10:28:18 -0700 Subject: [PATCH] subscriber: remove deprecated APIs (#1673) ## Motivation `tracing-subscriber` currently contains some APIs that were deprecated in the v0.2.x series: - `fmt::LayerBuilder`, which is now a type alias for `fmt::Layer` (as the `Layer` type can expose all the same methods as the builder) - `registry::SpanRef::parent_id`, which doesn't play nice with per-layer filtering, - `fmt::Layer::inherit_fields`, which no longer does anything as it's now the default behavior - `fmt::Layer::on_event`, which was renamed to `fmt_event` - the `SpanRef::parents` and `layer::Context::scope` iterators, which were replaced by the APIs added in #1431 and #1434 Prior to releasing v0.3, the deprecated APIs should be removed. ## Solution This branch deletes the deprecated APIs, with the exception of `SpanRef::parents` and `Context::scope` (which were already removed in 240d11a7ef70c1197f8071d98db74a02bd58fad9). Signed-off-by: Eliza Weisman --- tracing-subscriber/src/fmt/fmt_layer.rs | 47 ------------------------- tracing-subscriber/src/fmt/mod.rs | 23 +----------- tracing-subscriber/src/registry/mod.rs | 37 ------------------- 3 files changed, 1 insertion(+), 106 deletions(-) diff --git a/tracing-subscriber/src/fmt/fmt_layer.rs b/tracing-subscriber/src/fmt/fmt_layer.rs index 90269a7732..e889853048 100644 --- a/tracing-subscriber/src/fmt/fmt_layer.rs +++ b/tracing-subscriber/src/fmt/fmt_layer.rs @@ -72,34 +72,7 @@ pub struct Layer< _inner: PhantomData, } -/// A builder for [`Layer`](struct.Layer.html) that logs formatted representations of `tracing` -/// events and spans. -/// -/// **Note**: As of `tracing-subscriber` 0.2.4, the separate builder type is now -/// deprecated, as the `Layer` type itself supports all the builder's -/// configuration methods. This is now an alias for `Layer`. -#[deprecated( - since = "0.2.4", - note = "a separate layer builder type is not necessary, `Layer`s now support configuration" -)] -pub type LayerBuilder< - S, - N = format::DefaultFields, - E = format::Format, - W = fn() -> io::Stdout, -> = Layer; - impl Layer { - /// Returns a new [`LayerBuilder`](type.LayerBuilder.html) for configuring a `Layer`. - #[deprecated( - since = "0.2.4", - note = "a separate layer builder is not necessary, use `Layer::new`/`Layer::default` instead" - )] - #[allow(deprecated)] - pub fn builder() -> LayerBuilder { - Layer::default() - } - /// Returns a new [`Layer`](struct.Layer.html) with the default configuration. pub fn new() -> Self { Self::default() @@ -475,26 +448,6 @@ impl Layer { } } -#[allow(deprecated)] -impl LayerBuilder -where - S: Subscriber + for<'a> LookupSpan<'a>, - N: for<'writer> FormatFields<'writer> + 'static, - E: FormatEvent + 'static, - W: for<'writer> MakeWriter<'writer> + 'static, -{ - /// Builds a [`Layer`] with the provided configuration. - /// - /// [`Layer`]: struct.Layer.html - #[deprecated( - since = "0.2.4", - note = "`LayerBuilder` is no longer a separate type; this method is not necessary" - )] - pub fn finish(self) -> Layer { - self - } -} - impl Default for Layer { fn default() -> Self { Layer { diff --git a/tracing-subscriber/src/fmt/mod.rs b/tracing-subscriber/src/fmt/mod.rs index c6ec743e23..cd112c9f37 100644 --- a/tracing-subscriber/src/fmt/mod.rs +++ b/tracing-subscriber/src/fmt/mod.rs @@ -267,8 +267,7 @@ pub mod format; pub mod time; #[cfg_attr(docsrs, doc(cfg(all(feature = "fmt", feature = "std"))))] pub mod writer; -#[allow(deprecated)] -pub use fmt_layer::LayerBuilder; + pub use fmt_layer::{FmtContext, FormattedFields, Layer}; use crate::layer::Layer as _; @@ -1002,26 +1001,6 @@ impl SubscriberBuilder { } } - /// Sets whether or not spans inherit their parents' field values (disabled - /// by default). - #[deprecated(since = "0.2.0", note = "this no longer does anything")] - pub fn inherit_fields(self, inherit_fields: bool) -> Self { - let _ = inherit_fields; - self - } - - /// Sets the function that the subscriber being built should use to format - /// events that occur. - #[deprecated(since = "0.2.0", note = "renamed to `event_format`.")] - pub fn on_event(self, fmt_event: E2) -> SubscriberBuilder - where - E2: FormatEvent + 'static, - N: for<'writer> FormatFields<'writer> + 'static, - W: for<'writer> MakeWriter<'writer> + 'static, - { - self.event_format(fmt_event) - } - /// Sets the [`MakeWriter`] that the subscriber being built will use to write events. /// /// # Examples diff --git a/tracing-subscriber/src/registry/mod.rs b/tracing-subscriber/src/registry/mod.rs index 1eadc16045..f3b77b6a95 100644 --- a/tracing-subscriber/src/registry/mod.rs +++ b/tracing-subscriber/src/registry/mod.rs @@ -365,45 +365,8 @@ where self.data.metadata().fields() } - /// Returns the ID of this span's parent, or `None` if this span is the root - /// of its trace tree. - #[deprecated( - note = "this method cannot properly support per-layer filtering, and may \ - return the `Id` of a disabled span if per-layer filtering is in \ - use. use `.parent().map(SpanRef::id)` instead.", - since = "0.2.21" - )] - pub fn parent_id(&self) -> Option<&Id> { - // XXX(eliza): this doesn't work with PLF because the ID is potentially - // borrowed from a parent we got from the registry, rather than from - // `self`, so we can't return a borrowed parent. so, right now, we just - // return the actual parent ID, and ignore PLF. which is not great. - // - // i think if we want this to play nice with PLF, we should just change - // it to return the `Id` by value instead of `&Id` (which we ought to do - // anyway since an `Id` is just a word) but that's a breaking change. - // alternatively, we could deprecate this method since it can't support - // PLF in its current form (which is what we would want to do if we want - // to release PLF in a minor version)... - - // let mut id = self.data.parent()?; - // loop { - // // Is this parent enabled by our filter? - // if self - // .filter - // .map(|filter| self.registry.is_enabled_for(id, filter)) - // .unwrap_or(true) - // { - // return Some(id); - // } - // id = self.registry.span_data(id)?.parent()?; - // } - self.data.parent() - } - /// Returns a `SpanRef` describing this span's parent, or `None` if this /// span is the root of its trace tree. - pub fn parent(&self) -> Option { let id = self.data.parent()?; let data = self.registry.span_data(id)?;