-
Notifications
You must be signed in to change notification settings - Fork 95
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
Create a match
and/or in
(also not-in
) operator
#822
Comments
Original requestor here :-) For string types, regexp is more general for sure. But I think, even for programmers, writing the I think it'd also be nice to round out the rules language with disjunction and negation. :-) Aside: I had secretly been hoping that since you and @TylerHelmuth are owners of |
OTTL in Refinery might happen some day, but it isn't a top priority at the moment. We'd have to build our own contexts and the framework very much wants you to be using the collector's underlying data structure to be otlp but we have honeycomb events. We are still very much involved with OTTL in the collector. |
I'm actually pretty tempted to do both. They seem to have distinct use cases. I'm going to plan to do at least one of them for 2.2. |
Similar to having an |
match
or in
operatormatch
and/or in
operator
match
and/or in
operatormatch
and/or in
(also not-in
) operator
## Which problem is this PR solving? - Adds a regular expression `matches` operator to rules which should make some rules easier to write, especially when dealing with URLs or complex string fields. ## Short description of the changes - Add `matches` operator - Remove some unused switch cases from `conditionMatchesOperator` (to avoid implementing another one) - Add tests for it This is part of #822. This one will need further documentation, but that will be addressed in a separate PR.
@kentquirk I believe this can be considered closed pending #939 has now merged? |
@MikeGoldsmith I was also working on |
Is your feature request related to a problem? Please describe.
Sometimes it would be nice to be able to test a field for multiple values or a more complex form of containment, since the rules language doesn't support an
or
semantic.Describe the solution you'd like
One option is an operator
in
, where the Value field is a list of possible values. If the specified field matches any of the values then it would succeed. This requires allowing the value field to be a list and adding code to support it when reading configuration files. It could support lists of any datatype -- for example, a list of numeric error codes.This is easy to document and validate, but limited in that it only supports a list of exact matches.
An alternative is an operator
match
, which would accept for its Value field a Go-style regular expression. During parse time the Matches function would be constructed to pre-parse the regexp so that rule evaluation is just calling the match function on it. We would also have to make the validation code check that it could be parsed. All columns would be coerced to strings before matching (it would have an implicit Datatype of "string").This is a bit harder to explain to non-programmers, but powerful in that it can match a list like 'in' would use, but could also match more complex patterns.
Context
See original request in Pollinators slack.
The text was updated successfully, but these errors were encountered: