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: better default filtering #336
Conversation
I'm a bit confused by the description and change here. The behavior I'd like to see is that, regardless of whether the In addition to the high potential surprise, it looks like this change preserves the default behavior of displaying everything, which is practically unusable if you're using tokio (or any hypothetical other library that contains many trace statements). |
To clarify, my suggestion was that the default |
Ah, I misunderstood your suggestion. Thanks for clarifying that. This makes significantly more sense. |
This changes the `FmtSubscriber` type to default to using `Filter::from_default_env` when the filter feature flag is enabled. Rather than conditionally producing a layered or un-layered subscriber, we now wrap the layered type with a new type implementing `Subscriber` to make the API more consistent across feature flags. Closes #331 Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
262b3c3
to
fbe9450
Compare
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
@Ralith I've changed this up a bit so that it actually implements the behavior you suggested (which, IMO, makes significantly more sense). The default max level is now always Let me know what you think now? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks awesome, thanks! I think this will make the stack a lot more approachable.
It might be clearer to rename the type (and feature) from Filter
to EnvFilter
or similar, but that can be handled independently of this change.
@Ralith I also thought renaming to `EnvFilter` (and the corresponding
feature flag) was probably a good idea, but I wanted to do that in a
separate branch since there would be a lot of find-and-replace.
…On Tue, Sep 10, 2019 at 11:40 AM Benjamin Saunders ***@***.***> wrote:
***@***.**** approved this pull request.
Looks awesome, thanks! I think this will make the stack a lot more
approachable.
It might be clearer to rename the type (and feature) from Filter to
EnvFilter or similar, but that can be handled independently of this
change.
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#336?email_source=notifications&email_token=AAVKXMWBX6PZ3UORZYI327DQI7SYTA5CNFSM4IVA4ME2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCEIXKSY#pullrequestreview-286356811>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAVKXMRNCCBGCCYT2ADARADQI7SYTANCNFSM4IVA4MEQ>
.
|
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
51d1608
to
556a3d6
Compare
This branch renames `Filter` to `EnvFilter` and deprecates the previous name, as suggested in #336 (review). This should make the difference between an `EnvFilter` and a `LevelFilter` clearer. The `filter` feature has also been deprecated in favor of `env-filter`. Co-Authored-By: Benjamin Saunders <ben.e.saunders@gmail.com> Signed-off-by: Eliza Weisman <eliza@buoyant.io>
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>
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>
### 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>
Feature Request
Crates
tracing-subscriber
Motivation
Currently, the
tracing-subscriber
FmtSubscriber::default
implementation defaults to no filtering. This means that all
instrumentation, including extremely verbose
trace
-level diagnosticsfrom crates like
tokio
are enabled by default.This is because the subscriber itself does not implement filtering, in
order to allow it to be composed with filters implemented by
Layer
s.However, defaulting to no filtering at all is definitely a surprising
behavior. I didn't want to conditionally return a different type based
on whether or not filtering was enabled by the
filter
feature flag,but this is probably not worth the confusion introduced by this
behavior. We should make this more intuitive.
Solution
This branch changes
tracing-subscriber
to default to enablingthe
INFO
level and above. If thefilter
feature flag is enabled,users may opt-in to
env_logger
-style filtering. Additionally,regardless of feature flags, a new
with_max_level
method isadded to the
FmtSubscriber
builder, which takes aLevel
orLevelFilter
.LevelFilter
now implementsLayer
by enablingany spans and events that are less than or equal to that
Level
.Fixes: #331
Fixes: #332