Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

subscriber: fix incorrect filtering for tracing-log events #344

Merged
merged 3 commits into from Sep 12, 2019

Conversation

hawkw
Copy link
Member

@hawkw hawkw commented Sep 12, 2019

Motivation

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.

Solution

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.

This fixes the regression reported by @samscott89.

Signed-off-by: Eliza Weisman eliza@buoyant.io

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
@hawkw hawkw added the kind/bug Something isn't working label Sep 12, 2019
@hawkw hawkw requested a review from a team September 12, 2019 20:27
@hawkw hawkw self-assigned this Sep 12, 2019
@github-actions github-actions bot added the crate/subscriber Related to the `tracing-subscriber` crate label Sep 12, 2019
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>
Copy link
Contributor

@samscott89 samscott89 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Also confirmed locally that this fixes the behaviour I was seeing.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
@hawkw hawkw merged commit 520e4eb into master Sep 12, 2019
hawkw added a commit that referenced this pull request Sep 12, 2019
Fixed:

- `EnvFilter` ignoring directives with targets that are the same number
  of characters (#333)
- `EnvFilter` failing to properly apply filter directives to events
  generated from `log` records by`tracing-log` (#344)

Changed:

- Renamed `Filter` to `EnvFilter`, deprecated `Filter` (#339)
- Renamed "filter" feature flag to "env-filter", deprecated "filter" (#339)
- `FmtSubscriber` now defaults to enabling only the `INFO` level and
  above when a max level filter or `EnvFilter` is not set (#336)

Added:

- `EnvFilter::add_directive` to add new directives to filters after they
  are constructed (#334)
- `fmt::Builder::with_max_level` to set a global level filter for a
  `FmtSubscriber` without requiring the use of `EnvFilter` (#336)
- `Layer` implementation for `LevelFilter` (#336)
- `EnvFilter` now implements `fmt::Display` (#329)

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
hawkw added a commit that referenced this pull request Sep 13, 2019
Fixed:

- `EnvFilter` ignoring directives with targets that are the same number
  of characters (#333)
- `EnvFilter` failing to properly apply filter directives to events
  generated from `log` records by`tracing-log` (#344)

Changed:

- Renamed `Filter` to `EnvFilter`, deprecated `Filter` (#339)
- Renamed "filter" feature flag to "env-filter", deprecated "filter" (#339)
- `FmtSubscriber` now defaults to enabling only the `INFO` level and
  above when a max level filter or `EnvFilter` is not set (#336)
- Made `parking_lot` dependency an opt-in feature flag (#348)

Added:

- `EnvFilter::add_directive` to add new directives to filters after they
  are constructed (#334)
- `fmt::Builder::with_max_level` to set a global level filter for a
  `FmtSubscriber` without requiring the use of `EnvFilter` (#336)
- `Layer` implementation for `LevelFilter` (#336)
- `EnvFilter` now implements `fmt::Display` (#329)

Removed:

- Removed dependency on `crossbeam-util` (#348)

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
hawkw added a commit that referenced this pull request Sep 13, 2019
### Fixed

- `EnvFilter` ignoring directives with targets that are the same number
  of characters (#333)
- `EnvFilter` failing to properly apply filter directives to events
  generated from `log` records by`tracing-log` (#344)

### Changed

- Renamed `Filter` to `EnvFilter`, deprecated `Filter` (#339)
- Renamed "filter" feature flag to "env-filter", deprecated "filter" (#339)
- `FmtSubscriber` now defaults to enabling only the `INFO` level and
  above when a max level filter or `EnvFilter` is not set (#336)

### Added:

- `EnvFilter::add_directive` to add new directives to filters after they
  are constructed (#334)
- `fmt::Builder::with_max_level` to set a global level filter for a
  `FmtSubscriber` without requiring the use of `EnvFilter` (#336)
- `Layer` implementation for `LevelFilter` (#336)
- `EnvFilter` now implements `fmt::Display` (#329)

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
hawkw added a commit to linkerd/linkerd2-proxy that referenced this pull request Sep 13, 2019
Updating to the latest versions of the `tracing` and
`tracing-subscriber` crates picks up a few changes that might be
relevant to us:

- tokio-rs/tracing#333: Fix an issue where filtering directives could
  sometimes be ignored
- tokio-rs/tracing#344: Fix for filters not applying to events generated
  from `log` records
- tokio-rs/tracing#346: Dependencies using `tracing`'s `log` back-compat
  alongside the `log` record to `tracing` event conversion layer will no
  longer result in duplicate events

Additionally, `tracing-subscriber` 0.1.2 removed some dependencies that
were previously on by default, and feature flagged others; I've tweaked
the feature flags that we enable so we now have fewer transitive deps in
our lockfile :D

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
hawkw added a commit to linkerd/linkerd2-proxy that referenced this pull request Sep 18, 2019
* logging: update `tracing` and `tracing-subscriber`

Updating to the latest versions of the `tracing` and
`tracing-subscriber` crates picks up a few changes that might be
relevant to us:

- tokio-rs/tracing#333: Fix an issue where filtering directives could
  sometimes be ignored
- tokio-rs/tracing#344: Fix for filters not applying to events generated
  from `log` records
- tokio-rs/tracing#346: Dependencies using `tracing`'s `log` back-compat
  alongside the `log` record to `tracing` event conversion layer will no
  longer result in duplicate events

Additionally, `tracing-subscriber` 0.1.2 removed some dependencies that
were previously on by default, and feature flagged others; I've tweaked
the feature flags that we enable so we now have fewer transitive deps in
our lockfile :D

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
panthervis added a commit to panthervis/linkerd2-proxy that referenced this pull request Oct 8, 2021
* logging: update `tracing` and `tracing-subscriber`

Updating to the latest versions of the `tracing` and
`tracing-subscriber` crates picks up a few changes that might be
relevant to us:

- tokio-rs/tracing#333: Fix an issue where filtering directives could
  sometimes be ignored
- tokio-rs/tracing#344: Fix for filters not applying to events generated
  from `log` records
- tokio-rs/tracing#346: Dependencies using `tracing`'s `log` back-compat
  alongside the `log` record to `tracing` event conversion layer will no
  longer result in duplicate events

Additionally, `tracing-subscriber` 0.1.2 removed some dependencies that
were previously on by default, and feature flagged others; I've tweaked
the feature flags that we enable so we now have fewer transitive deps in
our lockfile :D

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crate/subscriber Related to the `tracing-subscriber` crate kind/bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants