Skip to content

Commit

Permalink
subscriber: remove deprecated APIs (#1673)
Browse files Browse the repository at this point in the history
## 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
240d11a).

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
  • Loading branch information
hawkw committed Oct 22, 2021
1 parent 7d3bff8 commit a927607
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 106 deletions.
47 changes: 0 additions & 47 deletions tracing-subscriber/src/fmt/fmt_layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,34 +72,7 @@ pub struct Layer<
_inner: PhantomData<S>,
}

/// 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<format::Full>,
W = fn() -> io::Stdout,
> = Layer<S, N, E, W>;

impl<S> Layer<S> {
/// 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<S> {
Layer::default()
}

/// Returns a new [`Layer`](struct.Layer.html) with the default configuration.
pub fn new() -> Self {
Self::default()
Expand Down Expand Up @@ -475,26 +448,6 @@ impl<S, N, E, W> Layer<S, N, E, W> {
}
}

#[allow(deprecated)]
impl<S, N, E, W> LayerBuilder<S, N, E, W>
where
S: Subscriber + for<'a> LookupSpan<'a>,
N: for<'writer> FormatFields<'writer> + 'static,
E: FormatEvent<S, N> + '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<S, N, E, W> {
self
}
}

impl<S> Default for Layer<S> {
fn default() -> Self {
Layer {
Expand Down
23 changes: 1 addition & 22 deletions tracing-subscriber/src/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 _;
Expand Down Expand Up @@ -1002,26 +1001,6 @@ impl<N, E, F, W> SubscriberBuilder<N, E, F, W> {
}
}

/// 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<E2>(self, fmt_event: E2) -> SubscriberBuilder<N, E2, F, W>
where
E2: FormatEvent<Registry, N> + '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
Expand Down
37 changes: 0 additions & 37 deletions tracing-subscriber/src/registry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self> {
let id = self.data.parent()?;
let data = self.registry.span_data(id)?;
Expand Down

0 comments on commit a927607

Please sign in to comment.