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

[pkg/ottl] Allow Converter in constant BoolExpr #20911

Conversation

TylerHelmuth
Copy link
Member

Description:
This PR updates the OTTL grammar to allow Converters in constant BoolExpr. This means that instead of writing

... where IsMatch(attributes["host.name"], ".*localhost.*") == true

you may (it's your choice, both syntaxes are valid) simply write

... where IsMatch(attributes["host.name"], ".*localhost.*").

If the Converter returns a value that is not a bool an error is returned.

The Converter is treated like a literal true or false in a BooleanExpression and can be ANDed, ORed, grouped, and negated like other BooleanExpressions.

Link to tracking Issue:
I finally added this bc I didn't like typing == true while working on #18642.

Testing:
Updated unit tests

Documentation:
Updated OTTL documentation and the READMEs of components that were using the inefficient syntax.

@TylerHelmuth TylerHelmuth force-pushed the ottl-allow-converters-as-constbool branch from c310af5 to 1d7e2f9 Compare April 15, 2023 04:26
.chloggen/ottl-allow-converters-as-constbool.yaml Outdated Show resolved Hide resolved
pkg/ottl/boolean_value.go Outdated Show resolved Hide resolved
Copy link
Contributor

@evan-bradley evan-bradley left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@TylerHelmuth TylerHelmuth added the ready to merge Code review completed; ready to merge by maintainers label May 1, 2023
@TylerHelmuth TylerHelmuth merged commit 11096ef into open-telemetry:main May 1, 2023
@TylerHelmuth TylerHelmuth deleted the ottl-allow-converters-as-constbool branch May 1, 2023 19:57
@github-actions github-actions bot added this to the next release milestone May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
connector/count internal/filter pkg/ottl processor/filter Filter processor processor/routing Routing processor processor/transform Transform processor ready to merge Code review completed; ready to merge by maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants