Skip to content

Commit

Permalink
subscriber: rename Subscribe::new_span to on_new_span
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 #630
Closes #662
  • Loading branch information
hawkw committed Oct 22, 2021
1 parent 6aafe52 commit 303dbd0
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion tracing-error/src/subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ where
{
/// Notifies this subscriber that a new span was constructed with the given
/// `Attributes` and `Id`.
fn new_span(
fn on_new_span(
&self,
attrs: &span::Attributes<'_>,
id: &span::Id,
Expand Down
2 changes: 1 addition & 1 deletion tracing-journald/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl<C> tracing_subscriber::Subscribe<C> for Subscriber
where
C: Collect + for<'span> LookupSpan<'span>,
{
fn new_span(&self, attrs: &Attributes, id: &Id, ctx: Context<C>) {
fn on_new_span(&self, attrs: &Attributes, id: &Id, ctx: Context<C>) {
let span = ctx.span(id).expect("unknown span");
let mut buf = Vec::with_capacity(256);

Expand Down
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<C> tracing_subscriber::Subscribe<C> for RegistryAccessCollector
where
C: tracing_core::Collect + 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<C> tracing_subscriber::Subscribe<C> for OtelDataCollector
where
C: tracing_core::Collect + 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/subscriber.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<'_, C>) {
fn on_new_span(&self, attrs: &Attributes<'_>, id: &span::Id, ctx: Context<'_, C>) {
let span = ctx.span(id).expect("Span not found, this is a bug");
let mut extensions = span.extensions_mut();

Expand Down
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 @@ -442,7 +442,7 @@ impl<C: Collect> Subscribe<C> for EnvFilter {
false
}

fn new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, _: Context<'_, C>) {
fn on_new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, _: Context<'_, C>) {
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_subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ where
E: FormatEvent<C, N> + 'static,
W: for<'writer> MakeWriter<'writer> + 'static,
{
fn new_span(&self, attrs: &Attributes<'_>, id: &Id, ctx: Context<'_, C>) {
fn on_new_span(&self, attrs: &Attributes<'_>, id: &Id, ctx: Context<'_, C>) {
let span = ctx.span(id).expect("Span not found, this is a bug");
let mut extensions = span.extensions_mut();

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 @@ -542,7 +542,7 @@ mod tests {
where
C: Collect + for<'a> LookupSpan<'a>,
{
fn new_span(&self, _: &Attributes<'_>, id: &Id, ctx: Context<'_, C>) {
fn on_new_span(&self, _: &Attributes<'_>, id: &Id, ctx: Context<'_, C>) {
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 @@ -69,13 +69,13 @@ where
}

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

#[inline]
Expand Down
18 changes: 9 additions & 9 deletions tracing-subscriber/src/subscribe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ where

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

Expand Down Expand Up @@ -616,7 +616,7 @@ where

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

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

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

#[inline]
Expand Down Expand Up @@ -817,9 +817,9 @@ where
}

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

Expand Down Expand Up @@ -897,8 +897,8 @@ feature! {
macro_rules! subscriber_impl_body {
() => {
#[inline]
fn new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, C>) {
self.deref().new_span(attrs, id, ctx)
fn on_new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, C>) {
self.deref().on_new_span(attrs, id, ctx)
}

#[inline]
Expand Down

0 comments on commit 303dbd0

Please sign in to comment.