Skip to content
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

Allow empty value match for fields #3015

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MattesWhite
Copy link

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 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.

@MattesWhite MattesWhite requested review from hawkw, davidbarsky and a team as code owners June 23, 2024 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant