Skip to content

Commit b2f33e2

Browse files
committed
Update README
1 parent 41116c4 commit b2f33e2

File tree

1 file changed

+62
-14
lines changed

1 file changed

+62
-14
lines changed

README.md

+62-14
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,27 @@
22

33
A system for filtering/querying structured tracing records.
44

5-
Very much in-progress. **Approximately nothing works yet**.
5+
Very much in-progress. **Things are in various states of (non)functional**.
6+
7+
Currently only targets filtering events as they are collected. However, I would
8+
*like* to support filtering recorded events as well.
69

710
## Filters
811

12+
When you construct a `Filter` type, you determine which kind of filters it
13+
supports. You cannot mix different kinds of filters in one filtering layer.
14+
15+
Note that a complicated filter can slow down your tracing performance, so
16+
using a filter from an untrusted (i.e. user) source is typically not
17+
recommended. This is particularly important for legacy and query filters,
18+
however; because they use [regex-automata](https://lib.rs/crates/regex-automata)
19+
to implement unbuffered regex filtering, they are vulnerable to unbounded regex
20+
compilation time à la [CVE-20222-24713]. Simple filters do not do unbuffered
21+
regex evaluation, so instead use the regex crate directly, which has mitigated
22+
this issue.
23+
24+
[CVE-20222-24713]: https://github.com/rust-lang/regex/security/advisories/GHSA-m5pq-gvj9-9vr8
25+
926
### Simple filters
1027

1128
tracing-filter is 99.999% compatible with [env_logger](lib.rs/env_logger)'s
@@ -15,32 +32,63 @@ filter syntax. As such, you can write simple filters the way you always have:
1532
- `my_app=debug` — filter to `DEBUG` or higher events only from `my_app`
1633
- `warn,my_app::module=trace` — get warning events and trace `my_app::module`
1734
- `off` — disable all logging
18-
- `trace/foo`get all events whose message contains "`foo`"
35+
- `debug/foo`filter to `DEBUG` or higher events whose message contains "`foo`"
1936

2037
In general, the syntax is `target=level/regex`. An event is included if its
2138
target *starts with* the listed `target`, its level passes the `level` filter,
22-
and its message matches `regex`. The only non-compatible behavior is that to use
23-
a simple filter, the filter must not start with the character `(`. This only
24-
impacts log events that specify a custom `target`. Additionally, `/filter` can
25-
only be used with the `regex` feature; it's ignored otherwise. With the
26-
env_logger crate, it would be interpreted as a simple substring filter.
39+
and its message matches `regex`. With the env_logger crate, the regex string
40+
is a simple substring match if you don't enable the `regex` feature; with our
41+
simple filters,
42+
43+
**This should be 99%<sup>†</sup> functional in the `tracing_filter::simple` module.**
44+
45+
<sup>†</sup>: tracing does not allow filtering on events' fields' contents
46+
[yet](https://github.com/tokio-rs/tracing/pull/2008). tracing-filter chooses to
47+
just siliently ignore the regex filter for the time being (but it does validate
48+
the filter).
49+
50+
### Legacy filters
51+
52+
The filter syntax supported by [email protected]'s `EnvFilter`, complete
53+
with all of its p̛̭a͖͕ŕ̯̪̥͈̠̙̣s͙̪̮̟͠i̥̞̠n͍̙̭͡g̸̜̤̦̤̳͍ ͓͜ẉ̨̳̠̗̗i̱t͚̹͉̯h̢̩̤̹͙̩͙ ̪̻͈r̻̙̥̭̯̫e̮̭̞̣̮͕̪g҉̦͚̬̖e͇̕x̛͖̣̮̞̜ͅ "peculiarites"; 100% bug-for-bug compatible.
2754

28-
If the filter is a simple filter, it must entirely be a simple filter.
29-
You may not mix simple filters with query filters.
55+
As such, you can use all of the filters that you have been using:
56+
57+
- `warn` — filter to only events of level `WARN` or `ERROR`
58+
- `my_app=debug` — filter to `DEBUG` or higher events only from `my_app`
59+
- `warn,my_app::module=trace` — get warning events and trace `my_app::module`
60+
- `off` — disable all logging
61+
- `[span]=debug` — filter to `DEBUG` or higher events inside a span named `span`
62+
- `[{field}]` — filter to events with a field `field` or within a span with name `field`
63+
- `[{key=val}]` — filter to events within a span with field `key` that matches the regex `val`
64+
- `[{key=0}]` — filter to events within a span with field `key` that recorded a number that equals `0`
65+
- `[{key=true}]` — filter to events within a span with field `key` that recorded a boolean value of `true`
66+
- `target[span]` — filter to events within a span with target `target` and name `span`
67+
68+
In general, the syntax is `target[span{field=value}]=level`.
69+
70+
**This should be 100% functional in the `tracing_filter::legacy` module.**
3071

3172
### Query filters
3273

3374
Query filters are tracing-filter's way of selecting events and taking advantage
34-
of tracing's structured events.
75+
of tracing's structured events. Query filters are a 99% superset of simple
76+
filters; specifically, for each `,` separated directive, it's treated as a query
77+
filter if and only if it starts with `(`; otherwise it is treated as a simple
78+
filter.
79+
80+
**This is still undergoing design work.**
3581

3682
## Why not use tracing-filter?
3783

38-
- tracing-filter doesn't work yet
39-
- You want compatibility with [email protected]'s `EnvFilter`
40-
- You don't want to pull in a nonstandard tracing-subscriber layer
84+
- tracing-filter is highly experimental
85+
- tracing-filter is not officially supported by the tracing team
86+
- tracing-filter is not published to crates-io
87+
- tracing-filter works with the unpublished tracing 0.2.0 ecosystem
4188

4289
## Why use tracing-filter?
4390

44-
- More configurable than tracing-subscriber@0.2's `EnvFilter`
91+
- More configurable than tracing-subscriber@0.3's `EnvFilter`
4592
- You want your runtime filter syntax to work for serialized event queries
4693
- You like the author and want them to feel proud of themself
94+
- We have nice [miette](https://lib.rs/miette)-powered errors :smile:

0 commit comments

Comments
 (0)