Skip to content

Commit

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

## 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
tokio-rs#1983 (comment)),
but I wanted to make the change separately from PR tokio-rs#1983 so that we can
fix it on the main branch without waiting for tokio-rs#1983 to merge first.

## Solution

This branch, uh, you know... fixes that.
  • Loading branch information
hawkw authored and kaffarell committed May 22, 2024
1 parent 19f31d8 commit 02654d4
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 02654d4

Please sign in to comment.