Skip to content

Commit

Permalink
fix(subscriber): ignore metadata that is not a span or event (#554)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dinhani authored Jun 6, 2024
1 parent a0d20fd commit 852a977
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions console-subscriber/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,10 @@ where
S: Subscriber + for<'a> LookupSpan<'a>,
{
fn register_callsite(&self, meta: &'static Metadata<'static>) -> subscriber::Interest {
if !meta.is_span() && !meta.is_event() {
return subscriber::Interest::never();
}

let dropped = match (meta.name(), meta.target()) {
("runtime.spawn", _) | ("task", "tokio::task") => {
self.spawn_callsites.insert(meta);
Expand Down

0 comments on commit 852a977

Please sign in to comment.