Skip to content

Commit

Permalink
subscriber: remove deprecated APIs (tokio-rs#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 tokio-rs#1431 and tokio-rs#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 authored and kaffarell committed May 22, 2024
1 parent ca15327 commit 08a8c38
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 48 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
1 change: 0 additions & 1 deletion tracing-subscriber/src/registry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,6 @@ where

/// 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 08a8c38

Please sign in to comment.