tokio-rs / tracing

Application level tracing for Rust.
https://tracing.rs
MIT License
5.53k stars 726 forks source link

subscriber: added builder for filter Directive #3018

Open rustonaut opened 5 months ago

rustonaut commented 5 months ago

Motivation

  1. There are some filters which can not be created with the current Directive string repr syntax, like e.g. the strings bool, 1 or 2.3 or values containing characters including but not limited to }], (for some of this there are partial fixes in other PRS). Furthermore updating the syntax the accommodate this is always a potential braking change, one which also can be subtle to detect.

  2. Sometimes there is need to create Directives programmatically, e.g. from a different kind of logging config or to set more complicated defaults.

  3. We might want to add other matching capabilities in the future which might not be re presentable in the string syntax (or at least entail a braking change). Like e.g. matching fields regex, matching based on dyn Value, a field matching the string true and boolean true at the same time, etc.

By allowing programmatic creation of Directives we allow downstream users to work around existing issues, experiment with solution to such issues in external crates and in addition set the foundation for adding future matching capabilities in the future.

Solution

Cavets

Out of Scope

Workaround For: #1584, #1181 Fixes: #2507, #404 Refs: #1584, #1181