mirror of
https://github.com/tokio-rs/tracing.git
synced 2025-10-02 15:24:47 +00:00
subscriber: add Filter::on_record
callback
Currently, `Filter` only has the `on_new_span`, `on_enter`, `on_exit`, and `on_close` callbacks. This means it won't handle cases where a span records a new field value that changes its filter state. This branch adds the missing `on_record` callback. Signed-off-by: Eliza Weisman <eliza@buoyant.io>
This commit is contained in:
parent
5813899946
commit
5d33d38021
@ -2,7 +2,7 @@
|
|||||||
use crate::layer::{Context, Filter};
|
use crate::layer::{Context, Filter};
|
||||||
use std::{cmp, fmt, marker::PhantomData};
|
use std::{cmp, fmt, marker::PhantomData};
|
||||||
use tracing_core::{
|
use tracing_core::{
|
||||||
span::{Attributes, Id},
|
span::{Attributes, Id, Record},
|
||||||
subscriber::Interest,
|
subscriber::Interest,
|
||||||
LevelFilter, Metadata,
|
LevelFilter, Metadata,
|
||||||
};
|
};
|
||||||
@ -143,6 +143,12 @@ where
|
|||||||
self.b.on_new_span(attrs, id, ctx)
|
self.b.on_new_span(attrs, id, ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn on_record(&self, id: &Id, values: &Record<'_>, ctx: Context<'_, S>) {
|
||||||
|
self.a.on_record(id, values, ctx.clone());
|
||||||
|
self.b.on_record(id, values, ctx);
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn on_enter(&self, id: &Id, ctx: Context<'_, S>) {
|
fn on_enter(&self, id: &Id, ctx: Context<'_, S>) {
|
||||||
self.a.on_enter(id, ctx.clone());
|
self.a.on_enter(id, ctx.clone());
|
||||||
@ -324,6 +330,12 @@ where
|
|||||||
self.b.on_new_span(attrs, id, ctx)
|
self.b.on_new_span(attrs, id, ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn on_record(&self, id: &Id, values: &Record<'_>, ctx: Context<'_, S>) {
|
||||||
|
self.a.on_record(id, values, ctx.clone());
|
||||||
|
self.b.on_record(id, values, ctx);
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn on_enter(&self, id: &Id, ctx: Context<'_, S>) {
|
fn on_enter(&self, id: &Id, ctx: Context<'_, S>) {
|
||||||
self.a.on_enter(id, ctx.clone());
|
self.a.on_enter(id, ctx.clone());
|
||||||
@ -414,6 +426,11 @@ where
|
|||||||
self.a.on_new_span(attrs, id, ctx);
|
self.a.on_new_span(attrs, id, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn on_record(&self, id: &Id, values: &Record<'_>, ctx: Context<'_, S>) {
|
||||||
|
self.a.on_record(id, values, ctx.clone());
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn on_enter(&self, id: &Id, ctx: Context<'_, S>) {
|
fn on_enter(&self, id: &Id, ctx: Context<'_, S>) {
|
||||||
self.a.on_enter(id, ctx);
|
self.a.on_enter(id, ctx);
|
||||||
|
@ -592,6 +592,7 @@ where
|
|||||||
|
|
||||||
fn on_record(&self, span: &span::Id, values: &span::Record<'_>, cx: Context<'_, S>) {
|
fn on_record(&self, span: &span::Id, values: &span::Record<'_>, cx: Context<'_, S>) {
|
||||||
if let Some(cx) = cx.if_enabled_for(span, self.id()) {
|
if let Some(cx) = cx.if_enabled_for(span, self.id()) {
|
||||||
|
self.filter.on_record(span, values, cx.clone());
|
||||||
self.layer.on_record(span, values, cx)
|
self.layer.on_record(span, values, cx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1065,6 +1065,17 @@ feature! {
|
|||||||
let _ = (attrs, id, ctx);
|
let _ = (attrs, id, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// Notifies this filter that a span with the given `Id` recorded the given
|
||||||
|
/// `values`.
|
||||||
|
///
|
||||||
|
/// By default, this method does nothing. `Filter` implementations that
|
||||||
|
/// need to be notified when new spans are created can override this
|
||||||
|
/// method.
|
||||||
|
fn on_record(&self, id: &span::Id, values: &span::Record<'_>, ctx: Context<'_, S>) {
|
||||||
|
let _ = (id, values, ctx);
|
||||||
|
}
|
||||||
|
|
||||||
/// Notifies this filter that a span with the given ID was entered.
|
/// Notifies this filter that a span with the given ID was entered.
|
||||||
///
|
///
|
||||||
/// By default, this method does nothing. `Filter` implementations that
|
/// By default, this method does nothing. `Filter` implementations that
|
||||||
|
Loading…
x
Reference in New Issue
Block a user