Skip to content

Commit 8777d2c

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 c62dac9 commit 8777d2c

File tree

12 files changed

+22
-22
lines changed

12 files changed

+22
-22
lines changed

Diff for: tracing-error/src/layer.rs

+1-1
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;

Diff for: tracing-journald/src/lib.rs

+1-1
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

Diff for: tracing-opentelemetry/benches/trace.rs

+2-2
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,

Diff for: tracing-opentelemetry/src/layer.rs

+1-1
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

Diff for: tracing-subscriber/src/filter/env/mod.rs

+1-1
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);

Diff for: tracing-subscriber/src/filter/layer_filters.rs

+2-2
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

Diff for: tracing-subscriber/src/fmt/fmt_layer.rs

+1-1
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

Diff for: tracing-subscriber/src/layer/layered.rs

+4-4
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]

Diff for: tracing-subscriber/src/layer/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ where
650650

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

@@ -1089,9 +1089,9 @@ where
10891089
}
10901090

10911091
#[inline]
1092-
fn new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, S>) {
1092+
fn on_new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, S>) {
10931093
if let Some(ref inner) = self {
1094-
inner.new_span(attrs, id, ctx)
1094+
inner.on_new_span(attrs, id, ctx)
10951095
}
10961096
}
10971097

@@ -1190,8 +1190,8 @@ feature! {
11901190
}
11911191

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

11971197
#[inline]

Diff for: tracing-subscriber/src/registry/sharded.rs

+1-1
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(());

Diff for: tracing-subscriber/src/reload.rs

+2-2
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]

Diff for: tracing-subscriber/tests/support.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ where
271271
// TODO: it should be possible to expect spans to follow from other spans
272272
}
273273

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

0 commit comments

Comments
 (0)