Skip to content

Commit 2b3aa06

Browse files
authored
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
1 parent 336f8ca commit 2b3aa06

File tree

9 files changed

+19
-19
lines changed

9 files changed

+19
-19
lines changed

tracing-error/src/subscriber.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ where
4343
{
4444
/// Notifies this subscriber that a new span was constructed with the given
4545
/// `Attributes` and `Id`.
46-
fn new_span(
46+
fn on_new_span(
4747
&self,
4848
attrs: &span::Attributes<'_>,
4949
id: &span::Id,

tracing-journald/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl<C> tracing_subscriber::Subscribe<C> for Subscriber
122122
where
123123
C: Collect + for<'span> LookupSpan<'span>,
124124
{
125-
fn new_span(&self, attrs: &Attributes, id: &Id, ctx: Context<C>) {
125+
fn on_new_span(&self, attrs: &Attributes, id: &Id, ctx: Context<C>) {
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<C> tracing_subscriber::Subscribe<C> for RegistryAccessCollector
6060
where
6161
C: tracing_core::Collect + 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<C> tracing_subscriber::Subscribe<C> for OtelDataCollector
8787
where
8888
C: tracing_core::Collect + 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/subscriber.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<'_, C>) {
413+
fn on_new_span(&self, attrs: &Attributes<'_>, id: &span::Id, ctx: Context<'_, C>) {
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
@@ -442,7 +442,7 @@ impl<C: Collect> Subscribe<C> for EnvFilter {
442442
false
443443
}
444444

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

tracing-subscriber/src/fmt/fmt_subscriber.rs

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

tracing-subscriber/src/registry/sharded.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ mod tests {
542542
where
543543
C: Collect + for<'a> LookupSpan<'a>,
544544
{
545-
fn new_span(&self, _: &Attributes<'_>, id: &Id, ctx: Context<'_, C>) {
545+
fn on_new_span(&self, _: &Attributes<'_>, id: &Id, ctx: Context<'_, C>) {
546546
let span = ctx.span(id).expect("Missing span; this is a bug");
547547
let mut lock = self.inner.lock().unwrap();
548548
let is_removed = Arc::new(());

tracing-subscriber/src/reload.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ where
6969
}
7070

7171
#[inline]
72-
fn new_span(
72+
fn on_new_span(
7373
&self,
7474
attrs: &span::Attributes<'_>,
7575
id: &span::Id,
7676
ctx: subscribe::Context<'_, C>,
7777
) {
78-
try_lock!(self.inner.read()).new_span(attrs, id, ctx)
78+
try_lock!(self.inner.read()).on_new_span(attrs, id, ctx)
7979
}
8080

8181
#[inline]

tracing-subscriber/src/subscribe.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ where
289289

290290
/// Notifies this subscriber that a new span was constructed with the given
291291
/// `Attributes` and `Id`.
292-
fn new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, C>) {
292+
fn on_new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, C>) {
293293
let _ = (attrs, id, ctx);
294294
}
295295

@@ -616,7 +616,7 @@ where
616616

617617
fn new_span(&self, span: &span::Attributes<'_>) -> span::Id {
618618
let id = self.inner.new_span(span);
619-
self.subscriber.new_span(span, &id, self.ctx());
619+
self.subscriber.on_new_span(span, &id, self.ctx());
620620
id
621621
}
622622

@@ -737,9 +737,9 @@ where
737737
}
738738

739739
#[inline]
740-
fn new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, C>) {
741-
self.inner.new_span(attrs, id, ctx.clone());
742-
self.subscriber.new_span(attrs, id, ctx);
740+
fn on_new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, C>) {
741+
self.inner.on_new_span(attrs, id, ctx.clone());
742+
self.subscriber.on_new_span(attrs, id, ctx);
743743
}
744744

745745
#[inline]
@@ -817,9 +817,9 @@ where
817817
}
818818

819819
#[inline]
820-
fn new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, C>) {
820+
fn on_new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, C>) {
821821
if let Some(ref inner) = self {
822-
inner.new_span(attrs, id, ctx)
822+
inner.on_new_span(attrs, id, ctx)
823823
}
824824
}
825825

@@ -897,8 +897,8 @@ feature! {
897897
macro_rules! subscriber_impl_body {
898898
() => {
899899
#[inline]
900-
fn new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, C>) {
901-
self.deref().new_span(attrs, id, ctx)
900+
fn on_new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, C>) {
901+
self.deref().on_new_span(attrs, id, ctx)
902902
}
903903

904904
#[inline]

0 commit comments

Comments
 (0)