Skip to content

Commit

Permalink
subscriber: rename Layer::new_span to on_new_span (tokio-rs#1674)
Browse files Browse the repository at this point in the history
While we're breaking things, we may as well do this as well.

Closes tokio-rs#630
Closes tokio-rs#662
  • Loading branch information
hawkw authored and kaffarell committed May 22, 2024
1 parent 81d4639 commit 6386a7c
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions tracing-opentelemetry/benches/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl<S> tracing_subscriber::Layer<S> for RegistryAccessLayer
where
S: tracing_core::Subscriber + for<'span> tracing_subscriber::registry::LookupSpan<'span>,
{
fn new_span(
fn on_new_span(
&self,
_attrs: &tracing_core::span::Attributes<'_>,
id: &tracing::span::Id,
Expand All @@ -87,7 +87,7 @@ impl<S> tracing_subscriber::Layer<S> for OtelDataLayer
where
S: tracing_core::Subscriber + for<'span> tracing_subscriber::registry::LookupSpan<'span>,
{
fn new_span(
fn on_new_span(
&self,
attrs: &tracing_core::span::Attributes<'_>,
id: &tracing::span::Id,
Expand Down
2 changes: 1 addition & 1 deletion tracing-opentelemetry/src/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<'_, S>) {
fn on_new_span(&self, attrs: &Attributes<'_>, id: &span::Id, ctx: Context<'_, S>) {
let span = ctx.span(id).expect("Span not found, this is a bug");
let mut extensions = span.extensions_mut();

Expand Down
4 changes: 2 additions & 2 deletions tracing-subscriber/src/filter/layer_filters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,9 @@ where
}
}

fn new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, cx: Context<'_, S>) {
fn on_new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, cx: Context<'_, S>) {
self.did_enable(|| {
self.layer.new_span(attrs, id, cx.with_filter(self.id()));
self.layer.on_new_span(attrs, id, cx.with_filter(self.id()));
})
}

Expand Down
2 changes: 1 addition & 1 deletion tracing-subscriber/src/fmt/fmt_layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ where
E: FormatEvent<S, N> + 'static,
W: for<'writer> MakeWriter<'writer> + 'static,
{
fn new_span(&self, attrs: &Attributes<'_>, id: &Id, ctx: Context<'_, S>) {
fn on_new_span(&self, attrs: &Attributes<'_>, id: &Id, ctx: Context<'_, S>) {
let span = ctx.span(id).expect("Span not found, this is a bug");
let mut extensions = span.extensions_mut();

Expand Down
8 changes: 4 additions & 4 deletions tracing-subscriber/src/layer/layered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ where

fn new_span(&self, span: &span::Attributes<'_>) -> span::Id {
let id = self.inner.new_span(span);
self.layer.new_span(span, &id, self.ctx());
self.layer.on_new_span(span, &id, self.ctx());
id
}

Expand Down Expand Up @@ -233,9 +233,9 @@ where
}

#[inline]
fn new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, S>) {
self.inner.new_span(attrs, id, ctx.clone());
self.layer.new_span(attrs, id, ctx);
fn on_new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, S>) {
self.inner.on_new_span(attrs, id, ctx.clone());
self.layer.on_new_span(attrs, id, ctx);
}

#[inline]
Expand Down
10 changes: 5 additions & 5 deletions tracing-subscriber/src/layer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ where

/// Notifies this layer that a new span was constructed with the given
/// `Attributes` and `Id`.
fn new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, S>) {
fn on_new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, S>) {
let _ = (attrs, id, ctx);
}

Expand Down Expand Up @@ -1089,9 +1089,9 @@ where
}

#[inline]
fn new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, S>) {
fn on_new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, S>) {
if let Some(ref inner) = self {
inner.new_span(attrs, id, ctx)
inner.on_new_span(attrs, id, ctx)
}
}

Expand Down Expand Up @@ -1190,8 +1190,8 @@ feature! {
}

#[inline]
fn new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, S>) {
self.deref().new_span(attrs, id, ctx)
fn on_new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, S>) {
self.deref().on_new_span(attrs, id, ctx)
}

#[inline]
Expand Down
2 changes: 1 addition & 1 deletion tracing-subscriber/tests/support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ where
// TODO: it should be possible to expect spans to follow from other spans
}

fn new_span(&self, span: &Attributes<'_>, id: &Id, cx: Context<'_, S>) {
fn on_new_span(&self, span: &Attributes<'_>, id: &Id, cx: Context<'_, S>) {
let meta = span.metadata();
println!(
"[{}] new_span: name={:?}; target={:?}; id={:?};",
Expand Down

0 comments on commit 6386a7c

Please sign in to comment.