Skip to content

Commit 3566804

Browse files
committed
subscriber: rename Layer::new_span to on_new_span (#1674)
While we're breaking things, we may as well do this as well. Closes #630 Closes #662
1 parent 957b5e3 commit 3566804

File tree

11 files changed

+17
-17
lines changed

11 files changed

+17
-17
lines changed

tracing-error/src/layer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ where
4040
{
4141
/// Notifies this layer that a new span was constructed with the given
4242
/// `Attributes` and `Id`.
43-
fn new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: layer::Context<'_, S>) {
43+
fn on_new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: layer::Context<'_, S>) {
4444
let span = ctx.span(id).expect("span must already exist!");
4545
if span.extensions().get::<FormattedFields<F>>().is_some() {
4646
return;

tracing-journald/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl<S> tracing_subscriber::Layer<S> for Layer
122122
where
123123
S: Subscriber + for<'span> LookupSpan<'span>,
124124
{
125-
fn new_span(&self, attrs: &Attributes, id: &Id, ctx: Context<S>) {
125+
fn on_new_span(&self, attrs: &Attributes, id: &Id, ctx: Context<'_, S>) {
126126
let span = ctx.span(id).expect("unknown span");
127127
let mut buf = Vec::with_capacity(256);
128128

tracing-opentelemetry/benches/trace.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl<S> tracing_subscriber::Layer<S> for RegistryAccessLayer
6060
where
6161
S: tracing_core::Subscriber + for<'span> tracing_subscriber::registry::LookupSpan<'span>,
6262
{
63-
fn new_span(
63+
fn on_new_span(
6464
&self,
6565
_attrs: &tracing_core::span::Attributes<'_>,
6666
id: &tracing::span::Id,
@@ -87,7 +87,7 @@ impl<S> tracing_subscriber::Layer<S> for OtelDataLayer
8787
where
8888
S: tracing_core::Subscriber + for<'span> tracing_subscriber::registry::LookupSpan<'span>,
8989
{
90-
fn new_span(
90+
fn on_new_span(
9191
&self,
9292
attrs: &tracing_core::span::Attributes<'_>,
9393
id: &tracing::span::Id,

tracing-opentelemetry/src/layer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ where
410410
///
411411
/// [OpenTelemetry `Span`]: opentelemetry::trace::Span
412412
/// [tracing `Span`]: tracing::Span
413-
fn new_span(&self, attrs: &Attributes<'_>, id: &span::Id, ctx: Context<'_, S>) {
413+
fn on_new_span(&self, attrs: &Attributes<'_>, id: &span::Id, ctx: Context<'_, S>) {
414414
let span = ctx.span(id).expect("Span not found, this is a bug");
415415
let mut extensions = span.extensions_mut();
416416

tracing-subscriber/src/filter/env/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ impl<S: Subscriber> Layer<S> for EnvFilter {
443443
false
444444
}
445445

446-
fn new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, _: Context<'_, S>) {
446+
fn on_new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, _: Context<'_, S>) {
447447
let by_cs = try_lock!(self.by_cs.read());
448448
if let Some(cs) = by_cs.get(&attrs.metadata().callsite()) {
449449
let span = cs.to_span_match(attrs);

tracing-subscriber/src/filter/layer_filters.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,9 @@ where
320320
}
321321
}
322322

323-
fn new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, cx: Context<'_, S>) {
323+
fn on_new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, cx: Context<'_, S>) {
324324
self.did_enable(|| {
325-
self.layer.new_span(attrs, id, cx.with_filter(self.id()));
325+
self.layer.on_new_span(attrs, id, cx.with_filter(self.id()));
326326
})
327327
}
328328

tracing-subscriber/src/fmt/fmt_layer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ where
557557
E: FormatEvent<S, N> + 'static,
558558
W: for<'writer> MakeWriter<'writer> + 'static,
559559
{
560-
fn new_span(&self, attrs: &Attributes<'_>, id: &Id, ctx: Context<'_, S>) {
560+
fn on_new_span(&self, attrs: &Attributes<'_>, id: &Id, ctx: Context<'_, S>) {
561561
let span = ctx.span(id).expect("Span not found, this is a bug");
562562
let mut extensions = span.extensions_mut();
563563

tracing-subscriber/src/layer/layered.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ where
9797

9898
fn new_span(&self, span: &span::Attributes<'_>) -> span::Id {
9999
let id = self.inner.new_span(span);
100-
self.layer.new_span(span, &id, self.ctx());
100+
self.layer.on_new_span(span, &id, self.ctx());
101101
id
102102
}
103103

@@ -233,9 +233,9 @@ where
233233
}
234234

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

241241
#[inline]

tracing-subscriber/src/registry/sharded.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ mod tests {
598598
where
599599
S: Subscriber + for<'a> LookupSpan<'a>,
600600
{
601-
fn new_span(&self, _: &Attributes<'_>, id: &Id, ctx: Context<'_, S>) {
601+
fn on_new_span(&self, _: &Attributes<'_>, id: &Id, ctx: Context<'_, S>) {
602602
let span = ctx.span(id).expect("Missing span; this is a bug");
603603
let mut lock = self.inner.lock().unwrap();
604604
let is_removed = Arc::new(());

tracing-subscriber/src/reload.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ where
7777
}
7878

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

8484
#[inline]

0 commit comments

Comments
 (0)