Skip to content

Commit

Permalink
subscriber: fall back to checking statics in enabled
Browse files Browse the repository at this point in the history
Currently, the `tracing-subscriber` `EnvFilter` does not properly enable
events that originate from the `tracing-log` `LogTracer` adapter. This
is because those events are supposed to be filtered only by `enabled`,
and will not generate proper `register_callsite` metadata. `EnvFilter`'s
`enabled` method will assume that an event was not enabled statically,
since `enabled` wouldn't have been called if the callsite was given the
`Always` interest. However, this doesn't take `tracing-log` into
account.

I've changed `EnvFilter` to always check against static filters in
`enabled` if the dynamic filters don't enable a given metadata. This
fixes the filtering of `tracing-log` events. I've also added tests that
fail against the current master.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
  • Loading branch information
hawkw committed Sep 12, 2019
1 parent 720da46 commit 0e9debb
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tracing-subscriber/src/filter/env/mod.rs
Expand Up @@ -231,11 +231,15 @@ impl<S: Subscriber> Layer<S> for EnvFilter {
}
}

// TODO: other filters...

false
// Otherwise, fall back to checking if the callsite is
// statically enabled.
// TODO(eliza): we *might* want to check this only if the `log`
// feature is enabled, since if this is a `tracing` event with a
// real callsite, it would already have been statically enabled...
self.statics.enabled(metadata)
}).unwrap_or_else(|| {
self.statics.enabled(metadata)
})
.unwrap_or(false)
}

fn new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, _: Context<'_, S>) {
Expand Down

0 comments on commit 0e9debb

Please sign in to comment.