mirror of
https://github.com/tokio-rs/tracing.git
synced 2025-09-28 13:31:52 +00:00
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
This commit is contained in:
parent
c62dac9f73
commit
8777d2c925
@ -40,7 +40,7 @@ where
|
||||
{
|
||||
/// Notifies this layer that a new span was constructed with the given
|
||||
/// `Attributes` and `Id`.
|
||||
fn new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: layer::Context<'_, S>) {
|
||||
fn on_new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: layer::Context<'_, S>) {
|
||||
let span = ctx.span(id).expect("span must already exist!");
|
||||
if span.extensions().get::<FormattedFields<F>>().is_some() {
|
||||
return;
|
||||
|
@ -122,7 +122,7 @@ impl<S> tracing_subscriber::Layer<S> for Layer
|
||||
where
|
||||
S: Subscriber + for<'span> LookupSpan<'span>,
|
||||
{
|
||||
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("unknown span");
|
||||
let mut buf = Vec::with_capacity(256);
|
||||
|
||||
|
@ -60,7 +60,7 @@ impl<S> tracing_subscriber::Layer<S> for RegistryAccessLayer
|
||||
where
|
||||
S: tracing_core::Subscriber + for<'span> tracing_subscriber::registry::LookupSpan<'span>,
|
||||
{
|
||||
fn new_span(
|
||||
fn on_new_span(
|
||||
&self,
|
||||
_attrs: &tracing_core::span::Attributes<'_>,
|
||||
id: &tracing::span::Id,
|
||||
@ -87,7 +87,7 @@ impl<S> tracing_subscriber::Layer<S> for OtelDataLayer
|
||||
where
|
||||
S: tracing_core::Subscriber + for<'span> tracing_subscriber::registry::LookupSpan<'span>,
|
||||
{
|
||||
fn new_span(
|
||||
fn on_new_span(
|
||||
&self,
|
||||
attrs: &tracing_core::span::Attributes<'_>,
|
||||
id: &tracing::span::Id,
|
||||
|
@ -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<'_, S>) {
|
||||
fn on_new_span(&self, attrs: &Attributes<'_>, id: &span::Id, ctx: Context<'_, S>) {
|
||||
let span = ctx.span(id).expect("Span not found, this is a bug");
|
||||
let mut extensions = span.extensions_mut();
|
||||
|
||||
|
2
tracing-subscriber/src/filter/env/mod.rs
vendored
2
tracing-subscriber/src/filter/env/mod.rs
vendored
@ -443,7 +443,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);
|
||||
|
@ -320,9 +320,9 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
fn new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, cx: Context<'_, S>) {
|
||||
fn on_new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, cx: Context<'_, S>) {
|
||||
self.did_enable(|| {
|
||||
self.layer.new_span(attrs, id, cx.with_filter(self.id()));
|
||||
self.layer.on_new_span(attrs, id, cx.with_filter(self.id()));
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -557,7 +557,7 @@ where
|
||||
E: FormatEvent<S, N> + 'static,
|
||||
W: for<'writer> MakeWriter<'writer> + '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();
|
||||
|
||||
|
@ -97,7 +97,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
|
||||
}
|
||||
|
||||
@ -233,9 +233,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]
|
||||
|
@ -650,7 +650,7 @@ where
|
||||
|
||||
/// Notifies this layer that a new span was constructed with the given
|
||||
/// `Attributes` and `Id`.
|
||||
fn new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, S>) {
|
||||
fn on_new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, S>) {
|
||||
let _ = (attrs, id, ctx);
|
||||
}
|
||||
|
||||
@ -1089,9 +1089,9 @@ where
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, S>) {
|
||||
fn on_new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, S>) {
|
||||
if let Some(ref inner) = self {
|
||||
inner.new_span(attrs, id, ctx)
|
||||
inner.on_new_span(attrs, id, ctx)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1190,8 +1190,8 @@ feature! {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, S>) {
|
||||
self.deref().new_span(attrs, id, ctx)
|
||||
fn on_new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, S>) {
|
||||
self.deref().on_new_span(attrs, id, ctx)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -598,7 +598,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(());
|
||||
|
@ -77,8 +77,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]
|
||||
|
@ -271,7 +271,7 @@ where
|
||||
// TODO: it should be possible to expect spans to follow from other spans
|
||||
}
|
||||
|
||||
fn new_span(&self, span: &Attributes<'_>, id: &Id, cx: Context<'_, S>) {
|
||||
fn on_new_span(&self, span: &Attributes<'_>, id: &Id, cx: Context<'_, S>) {
|
||||
let meta = span.metadata();
|
||||
println!(
|
||||
"[{}] new_span: name={:?}; target={:?}; id={:?};",
|
||||
|
Loading…
x
Reference in New Issue
Block a user