Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(subsriber): rename Layer::new_span method to Layer::on_new_span for consistency #662

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tracing-subscriber/src/filter/env/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ impl<S: Subscriber> Layer<S> for EnvFilter {
false
}

fn new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, _: Context<'_, S>) {
fn on_new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, _: Context<'_, S>) {
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);
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 @@ -423,7 +423,7 @@ where
E: FormatEvent<S, N> + 'static,
W: MakeWriter + '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
15 changes: 11 additions & 4 deletions tracing-subscriber/src/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,14 @@ where

/// Notifies this layer that a new span was constructed with the given
/// `Attributes` and `Id`.
#[deprecated(since = "0.3.0", note = "Please use the on_new_span method instead")]
fn new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, S>) {
self.on_new_span(attrs, id, ctx)
}

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

Expand Down Expand Up @@ -580,7 +587,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 @@ -698,9 +705,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
2 changes: 1 addition & 1 deletion tracing-subscriber/src/registry/sharded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ mod tests {
where
S: Subscriber + for<'a> LookupSpan<'a>,
{
fn new_span(&self, _: &Attributes<'_>, id: &Id, ctx: Context<'_, S>) {
fn on_new_span(&self, _: &Attributes<'_>, id: &Id, ctx: Context<'_, S>) {
let span = ctx.span(id).expect("Missing span; this is a bug");
let mut lock = self.inner.lock().unwrap();
let is_removed = Arc::new(());
Expand Down
4 changes: 2 additions & 2 deletions tracing-subscriber/src/reload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ where
}

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

#[inline]
Expand Down