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 Directives 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.
Motivation
In the current version of
EnvFilter
, the directive[span{field=}]
does not work as expected.The directive
[span{field}]
filter for all spansspan
that have a fieldfield
while the directive[{field=a}]
filters for all spansspan
where the fieldfield
has the valuea
. In contrast, the directive[span{field=}]
filters only for spansspan
. IMHO this is unexpected behavior.Solution
Digging into the code for parsing
Directive
s the regex for field matches didn't consider thefield=
case. This PR changes the regex so thatfield=
is interpreted as a match on an empty string.With regex enabled this means that now
field=
behaves likefield
.Alternative solution
Instead of accepting the
field=
directive, it could trigger an error instead invalidating the whole directive.