Skip to content

Commit

Permalink
subscriber: fix Filtered::on_exit calling on_enter by mistake (#2018
Browse files Browse the repository at this point in the history
)

## Motivation

Currently, the `Filtered` type's `Subscribe` impl accidentally calls the
inner `Filter`'s `on_enter` hook in the `on_exit` hook. This
is...obviously wrong, lol, and means that filters like `EnvFilter` will
never consider spans to have exited, breaking filtering behavior.

@tfreiberg-fastly originally noticed this bug (see
#1983 (comment)),
but I wanted to make the change separately from PR #1983 so that we can
fix it on the main branch without waiting for #1983 to merge first.

## Solution

This branch, uh, you know... fixes that.
  • Loading branch information
hawkw committed Mar 29, 2022
1 parent baaab24 commit 70fcfce
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tracing-subscriber/src/filter/subscriber_filters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ where

fn on_exit(&self, id: &span::Id, cx: Context<'_, C>) {
if let Some(cx) = cx.if_enabled_for(id, self.id()) {
self.filter.on_enter(id, cx.clone());
self.filter.on_exit(id, cx.clone());
self.subscriber.on_exit(id, cx);
}
}
Expand Down

0 comments on commit 70fcfce

Please sign in to comment.