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

[chore][pkg/stanza] Upgrade expr module to latest #24648

Merged
merged 1 commit into from
Jul 31, 2023

Conversation

djaglowski
Copy link
Member

@djaglowski djaglowski commented Jul 27, 2023

Fixes #24575

This upgrade involves a workaround for a grammar conflict introduced in this PR.

pkg/stanza previously added a custom function to the syntax called env(), which allows users to fetch values from OS environment variables.

The latest version of the expr module introduced its own keyword env, but the meaning and usage were different. Still, the overlap was enough to cause failures in the compilation and rendering of expressions.

The new syntax was introduced as a Membership Operator, which means that the proper way to use it is with square brackets, env[]. This resulted in our custom env() syntax being flagged as invalid.

More importantly, the meaning of the new env[] is not the same. While we use env() to lookup values from the OS environment, env[] is meant to pull values from an in-memory map. This map allows for customizations of the syntax, such as those that allow users to reference "body" or "attributes" within an expression, but it does not contain OS environment variables. Therefore, accessing it with the new syntax is of limited value to users.

The solution used here is a Patch option which allows us to inspect and modify elements of the grammar as an expression is being compiled. Fortunately, env() is understood to be a function call, while env[] is otherwise. This makes it possible to detect usage of our custom syntax and rename the function internally without any impact to the user.

The PR also standardizes all uses of expr.Compile within pkg/stanza to ensure they are using the new patch option.

@djaglowski djaglowski marked this pull request as ready for review July 27, 2023 16:24
@djaglowski djaglowski requested a review from a team July 27, 2023 16:24
Copy link
Member

@dmitryax dmitryax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@djaglowski djaglowski added the ready to merge Code review completed; ready to merge by maintainers label Jul 27, 2023
@djaglowski djaglowski merged commit 44e1f67 into open-telemetry:main Jul 31, 2023
@djaglowski djaglowski deleted the pkg-stanza-expr branch July 31, 2023 13:56
@github-actions github-actions bot added this to the next release milestone Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[pkg/stanza] Upgrade to github.com/antonmedv/expr v1.12.7 breaks tests
4 participants