Skip to content

Commit 852a977

Browse files
authored
fix(subscriber): ignore metadata that is not a span or event (#554)
As described in #553, there are parts of code that expects tracing `Metadata` to be of type `EVENT` or `SPAN`. This PR ensure that any tracing metadata with a different type will be ignored instead of panicking when running in debug mode when converting from `tracing_core::Metadata`: https://github.com/tokio-rs/console/blob/60bcf87537d414b21efbd84159207f9ecda5e914/console-api/src/common.rs#L48
1 parent a0d20fd commit 852a977

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

console-subscriber/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,10 @@ where
529529
S: Subscriber + for<'a> LookupSpan<'a>,
530530
{
531531
fn register_callsite(&self, meta: &'static Metadata<'static>) -> subscriber::Interest {
532+
if !meta.is_span() && !meta.is_event() {
533+
return subscriber::Interest::never();
534+
}
535+
532536
let dropped = match (meta.name(), meta.target()) {
533537
("runtime.spawn", _) | ("task", "tokio::task") => {
534538
self.spawn_callsites.insert(meta);

0 commit comments

Comments
 (0)