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 `Layer` 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 authored Mar 24, 2022
1 parent b1123e4 commit 5813899
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tracing-subscriber/src/filter/layer_filters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ where

fn on_exit(&self, id: &span::Id, cx: Context<'_, S>) {
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.layer.on_exit(id, cx);
}
}
Expand Down

0 comments on commit 5813899

Please sign in to comment.