Skip to content

Commit

Permalink
subscriber: rename trait CollectorExt to CollectExt (#1115)
Browse files Browse the repository at this point in the history
The trait being augmented is the 'Collect' trait, so name the trait
that extends should be called 'CollectExt'.

This is in keeping with the extension trait naming conventions
documented in RFC 445 and the spirit of the discussion in
tokio-rs/tracing PR #1015.
  • Loading branch information
salewski authored Nov 21, 2020
1 parent 1f3e095 commit b3c1e0e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion examples/examples/opentelemetry-remote-context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use opentelemetry::{global, Context};
use std::collections::HashMap;
use tracing::span;
use tracing_opentelemetry::OpenTelemetrySpanExt;
use tracing_subscriber::subscribe::CollectorExt;
use tracing_subscriber::subscribe::CollectExt;
use tracing_subscriber::Registry;

fn make_request(_cx: Context) {
Expand Down
6 changes: 3 additions & 3 deletions tracing-opentelemetry/src/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ where
/// # Examples
///
/// ```rust,no_run
/// use tracing_subscriber::subscribe::CollectorExt;
/// use tracing_subscriber::subscribe::CollectExt;
/// use tracing_subscriber::Registry;
///
/// // Use the tracing subscriber `Registry`, or any other subscriber
Expand Down Expand Up @@ -249,7 +249,7 @@ where
///
/// ```no_run
/// use tracing_opentelemetry::OpenTelemetryLayer;
/// use tracing_subscriber::subscribe::CollectorExt;
/// use tracing_subscriber::subscribe::CollectExt;
/// use tracing_subscriber::Registry;
///
/// // Create a jaeger exporter pipeline for a `trace_demo` service.
Expand Down Expand Up @@ -283,7 +283,7 @@ where
/// # Examples
///
/// ```no_run
/// use tracing_subscriber::subscribe::CollectorExt;
/// use tracing_subscriber::subscribe::CollectExt;
/// use tracing_subscriber::Registry;
///
/// // Create a jaeger exporter pipeline for a `trace_demo` service.
Expand Down
2 changes: 1 addition & 1 deletion tracing-opentelemetry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
//! ```
//! use opentelemetry::exporter::trace::stdout;
//! use tracing::{error, span};
//! use tracing_subscriber::subscribe::CollectorExt;
//! use tracing_subscriber::subscribe::CollectExt;
//! use tracing_subscriber::Registry;
//!
//! // Create a new OpenTelemetry pipeline
Expand Down
2 changes: 1 addition & 1 deletion tracing-subscriber/src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub use crate::field::{
RecordFields as __tracing_subscriber_field_RecordFields,
};
pub use crate::subscribe::{
CollectorExt as __tracing_subscriber_SubscriberExt, Subscribe as __tracing_subscriber_Layer,
CollectExt as __tracing_subscriber_SubscriberExt, Subscribe as __tracing_subscriber_Layer,
};

pub use crate::util::SubscriberInitExt as _;
28 changes: 16 additions & 12 deletions tracing-subscriber/src/subscribe.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//! A composable abstraction for building `Collector`s.
//! A composable abstraction for building [collector]s.
//!
//! [collector]: tracing_core::Collect
use tracing_core::{
collect::{Collect, Interest},
metadata::Metadata,
Expand All @@ -13,16 +15,18 @@ use std::{any::TypeId, marker::PhantomData};
///
/// The [`Collect`] trait in `tracing-core` represents the _complete_ set of
/// functionality required to consume `tracing` instrumentation. This means that
/// a single `Collector` instance is a self-contained implementation of a
/// a single [collector] instance is a self-contained implementation of a
/// complete strategy for collecting traces; but it _also_ means that the
/// `Collector` trait cannot easily be composed with other `Collector`s.
/// `Collect` trait cannot easily be composed with other `Collect`s.
///
/// In particular, collectors are responsible for generating [span IDs] and
/// assigning them to spans. Since these IDs must uniquely identify a span
/// within the context of the current trace, this means that there may only be
/// a single `Collector` for a given thread at any point in time —
/// a single [collector] for a given thread at any point in time —
/// otherwise, there would be no authoritative source of span IDs.
///
/// [collector]: tracing_core::Collect
///
/// On the other hand, the majority of the [`Collect`] trait's functionality
/// is composable: any number of collectors may _observe_ events, span entry
/// and exit, and so on, provided that there is a single authoritative source of
Expand All @@ -40,7 +44,7 @@ use std::{any::TypeId, marker::PhantomData};
/// particular `Collect` implementation, or additional trait bounds may be
/// added to constrain what types implementing `Collect` a subscriber can wrap.
///
/// Subscribers may be added to a `Collect` by using the [`CollectorExt::with`]
/// Subscribers may be added to a `Collect` by using the [`CollectExt::with`]
/// method, which is provided by `tracing-subscriber`'s [prelude]. This method
/// returns a [`Layered`] struct that implements `Collect` by composing the
/// subscriber with the collector.
Expand Down Expand Up @@ -143,8 +147,8 @@ use std::{any::TypeId, marker::PhantomData};
///
/// The [`Subscribe::with_collector` method][with-col] constructs the `Layered`
/// type from a `Subscribe` and `Collect`, and is called by
/// [`CollectorExt::with`]. In general, it is more idiomatic to use
/// `CollectorExt::with`, and treat `Subscribe::with_collector` as an
/// [`CollectExt::with`]. In general, it is more idiomatic to use
/// `CollectExt::with`, and treat `Subscribe::with_collector` as an
/// implementation detail, as `with_collector` calls must be nested, leading to
/// less clear code for the reader. However, subscribers which wish to perform
/// additional behavior when composed with a subscriber may provide their own
Expand Down Expand Up @@ -437,7 +441,7 @@ where
}
}

/// Composes this subscriber with the given collecto, returning a
/// Composes this subscriber with the given collector, returning a
/// `Layered` struct that implements [`Collect`].
///
/// The returned `Layered` subscriber will call the methods on this subscriber
Expand Down Expand Up @@ -501,8 +505,8 @@ where
}
}

/// Extension trait adding a `with(Subscriber)` combinator to `Collector`s.
pub trait CollectorExt: Collect + crate::sealed::Sealed {
/// Extension trait adding a `with(Subscriber)` combinator to `Collect`.
pub trait CollectExt: Collect + crate::sealed::Sealed {
/// Wraps `self` with the provided `layer`.
fn with<S>(self, subscriber: S) -> Layered<S, Self>
where
Expand Down Expand Up @@ -921,10 +925,10 @@ where
// }
// }

// === impl CollectorExt ===
// === impl CollectExt ===

impl<C: Collect> crate::sealed::Sealed for C {}
impl<C: Collect> CollectorExt for C {}
impl<C: Collect> CollectExt for C {}

// === impl Context ===

Expand Down

0 comments on commit b3c1e0e

Please sign in to comment.