tracing
tracing copied to clipboard
Allow empty value match for fields
Motivation
In the current version of EnvFilter
, the directive [span{field=}]
does not work as expected.
The directive [span{field}]
filter for all spans span
that have a field field
while the directive [{field=a}]
filters for all spans span
where the field field
has the value a
. In contrast, the directive [span{field=}]
filters only for spans span
. IMHO this is unexpected behavior.
Solution
Digging into the code for parsing Directive
s the regex for field matches didn't consider the field=
case. This PR changes the regex so that field=
is interpreted as a match on an empty string.
With regex enabled this means that now field=
behaves like field
.
Alternative solution
Instead of accepting the field=
directive, it could trigger an error instead invalidating the whole directive.