From 2b3aa06de43c8e199378b9e4962cb78e658631e5 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Fri, 22 Oct 2021 11:04:20 -0700 Subject: [PATCH] subscriber: rename `Subscribe::new_span` to `on_new_span` (#1674) While we're breaking things, we may as well do this as well. Closes #630 Closes #662 --- tracing-error/src/subscriber.rs | 2 +- tracing-journald/src/lib.rs | 2 +- tracing-opentelemetry/benches/trace.rs | 4 ++-- tracing-opentelemetry/src/subscriber.rs | 2 +- tracing-subscriber/src/filter/env/mod.rs | 2 +- tracing-subscriber/src/fmt/fmt_subscriber.rs | 2 +- tracing-subscriber/src/registry/sharded.rs | 2 +- tracing-subscriber/src/reload.rs | 4 ++-- tracing-subscriber/src/subscribe.rs | 18 +++++++++--------- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/tracing-error/src/subscriber.rs b/tracing-error/src/subscriber.rs index 2e81d2d921..f6840acc07 100644 --- a/tracing-error/src/subscriber.rs +++ b/tracing-error/src/subscriber.rs @@ -43,7 +43,7 @@ where { /// Notifies this subscriber that a new span was constructed with the given /// `Attributes` and `Id`. - fn new_span( + fn on_new_span( &self, attrs: &span::Attributes<'_>, id: &span::Id, diff --git a/tracing-journald/src/lib.rs b/tracing-journald/src/lib.rs index b40d946a3c..b185b80dfa 100644 --- a/tracing-journald/src/lib.rs +++ b/tracing-journald/src/lib.rs @@ -122,7 +122,7 @@ impl tracing_subscriber::Subscribe for Subscriber where C: Collect + for<'span> LookupSpan<'span>, { - fn new_span(&self, attrs: &Attributes, id: &Id, ctx: Context) { + fn on_new_span(&self, attrs: &Attributes, id: &Id, ctx: Context) { let span = ctx.span(id).expect("unknown span"); let mut buf = Vec::with_capacity(256); diff --git a/tracing-opentelemetry/benches/trace.rs b/tracing-opentelemetry/benches/trace.rs index 2912aab33b..3a578b59cc 100644 --- a/tracing-opentelemetry/benches/trace.rs +++ b/tracing-opentelemetry/benches/trace.rs @@ -60,7 +60,7 @@ impl tracing_subscriber::Subscribe for RegistryAccessCollector where C: tracing_core::Collect + for<'span> tracing_subscriber::registry::LookupSpan<'span>, { - fn new_span( + fn on_new_span( &self, _attrs: &tracing_core::span::Attributes<'_>, id: &tracing::span::Id, @@ -87,7 +87,7 @@ impl tracing_subscriber::Subscribe for OtelDataCollector where C: tracing_core::Collect + for<'span> tracing_subscriber::registry::LookupSpan<'span>, { - fn new_span( + fn on_new_span( &self, attrs: &tracing_core::span::Attributes<'_>, id: &tracing::span::Id, diff --git a/tracing-opentelemetry/src/subscriber.rs b/tracing-opentelemetry/src/subscriber.rs index c2499b704f..06453f843f 100644 --- a/tracing-opentelemetry/src/subscriber.rs +++ b/tracing-opentelemetry/src/subscriber.rs @@ -410,7 +410,7 @@ where /// /// [OpenTelemetry `Span`]: opentelemetry::trace::Span /// [tracing `Span`]: tracing::Span - fn new_span(&self, attrs: &Attributes<'_>, id: &span::Id, ctx: Context<'_, C>) { + fn on_new_span(&self, attrs: &Attributes<'_>, id: &span::Id, ctx: Context<'_, C>) { let span = ctx.span(id).expect("Span not found, this is a bug"); let mut extensions = span.extensions_mut(); diff --git a/tracing-subscriber/src/filter/env/mod.rs b/tracing-subscriber/src/filter/env/mod.rs index 721cf38d66..2c633f1d6b 100644 --- a/tracing-subscriber/src/filter/env/mod.rs +++ b/tracing-subscriber/src/filter/env/mod.rs @@ -442,7 +442,7 @@ impl Subscribe for EnvFilter { false } - fn new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, _: Context<'_, C>) { + fn on_new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, _: Context<'_, C>) { let by_cs = try_lock!(self.by_cs.read()); if let Some(cs) = by_cs.get(&attrs.metadata().callsite()) { let span = cs.to_span_match(attrs); diff --git a/tracing-subscriber/src/fmt/fmt_subscriber.rs b/tracing-subscriber/src/fmt/fmt_subscriber.rs index c41daedc3d..48fe9a8718 100644 --- a/tracing-subscriber/src/fmt/fmt_subscriber.rs +++ b/tracing-subscriber/src/fmt/fmt_subscriber.rs @@ -556,7 +556,7 @@ where E: FormatEvent + 'static, W: for<'writer> MakeWriter<'writer> + 'static, { - fn new_span(&self, attrs: &Attributes<'_>, id: &Id, ctx: Context<'_, C>) { + fn on_new_span(&self, attrs: &Attributes<'_>, id: &Id, ctx: Context<'_, C>) { let span = ctx.span(id).expect("Span not found, this is a bug"); let mut extensions = span.extensions_mut(); diff --git a/tracing-subscriber/src/registry/sharded.rs b/tracing-subscriber/src/registry/sharded.rs index c594d3f25c..b6ee290e12 100644 --- a/tracing-subscriber/src/registry/sharded.rs +++ b/tracing-subscriber/src/registry/sharded.rs @@ -542,7 +542,7 @@ mod tests { where C: Collect + for<'a> LookupSpan<'a>, { - fn new_span(&self, _: &Attributes<'_>, id: &Id, ctx: Context<'_, C>) { + fn on_new_span(&self, _: &Attributes<'_>, id: &Id, ctx: Context<'_, C>) { let span = ctx.span(id).expect("Missing span; this is a bug"); let mut lock = self.inner.lock().unwrap(); let is_removed = Arc::new(()); diff --git a/tracing-subscriber/src/reload.rs b/tracing-subscriber/src/reload.rs index 72f5caff62..d245731d54 100644 --- a/tracing-subscriber/src/reload.rs +++ b/tracing-subscriber/src/reload.rs @@ -69,13 +69,13 @@ where } #[inline] - fn new_span( + fn on_new_span( &self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: subscribe::Context<'_, C>, ) { - try_lock!(self.inner.read()).new_span(attrs, id, ctx) + try_lock!(self.inner.read()).on_new_span(attrs, id, ctx) } #[inline] diff --git a/tracing-subscriber/src/subscribe.rs b/tracing-subscriber/src/subscribe.rs index d0f5fef0a7..8550c28819 100644 --- a/tracing-subscriber/src/subscribe.rs +++ b/tracing-subscriber/src/subscribe.rs @@ -289,7 +289,7 @@ where /// Notifies this subscriber that a new span was constructed with the given /// `Attributes` and `Id`. - fn new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, C>) { + fn on_new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, C>) { let _ = (attrs, id, ctx); } @@ -616,7 +616,7 @@ where fn new_span(&self, span: &span::Attributes<'_>) -> span::Id { let id = self.inner.new_span(span); - self.subscriber.new_span(span, &id, self.ctx()); + self.subscriber.on_new_span(span, &id, self.ctx()); id } @@ -737,9 +737,9 @@ where } #[inline] - fn new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, C>) { - self.inner.new_span(attrs, id, ctx.clone()); - self.subscriber.new_span(attrs, id, ctx); + fn on_new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, C>) { + self.inner.on_new_span(attrs, id, ctx.clone()); + self.subscriber.on_new_span(attrs, id, ctx); } #[inline] @@ -817,9 +817,9 @@ where } #[inline] - fn new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, C>) { + fn on_new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, C>) { if let Some(ref inner) = self { - inner.new_span(attrs, id, ctx) + inner.on_new_span(attrs, id, ctx) } } @@ -897,8 +897,8 @@ feature! { macro_rules! subscriber_impl_body { () => { #[inline] - fn new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, C>) { - self.deref().new_span(attrs, id, ctx) + fn on_new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, C>) { + self.deref().on_new_span(attrs, id, ctx) } #[inline]