Skip to content

Commit bafa898

Browse files
add support for does not contain span filter operator (#175)
1 parent 27095cc commit bafa898

3 files changed

Lines changed: 14 additions & 0 deletions

File tree

span-processing-config-service-api/src/main/proto/org/hypertrace/span/processing/config/service/v1/span_filter.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ enum RelationalOperator {
5454
RELATIONAL_OPERATOR_EQUALS = 1;
5555
RELATIONAL_OPERATOR_NOT_EQUALS = 2;
5656
RELATIONAL_OPERATOR_CONTAINS = 3;
57+
RELATIONAL_OPERATOR_NOT_CONTAINS = 8;
5758
RELATIONAL_OPERATOR_STARTS_WITH = 4;
5859
RELATIONAL_OPERATOR_ENDS_WITH = 5;
5960
RELATIONAL_OPERATOR_REGEX_MATCH = 6;

span-processing-utils/src/main/java/org/hypertrace/config/span/processing/utils/SpanFilterMatcher.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ private boolean matches(String lhs, String rhs, RelationalOperator relationalOpe
103103
switch (relationalOperator) {
104104
case RELATIONAL_OPERATOR_CONTAINS:
105105
return lhs.contains(rhs);
106+
case RELATIONAL_OPERATOR_NOT_CONTAINS:
107+
return !lhs.contains(rhs);
106108
case RELATIONAL_OPERATOR_EQUALS:
107109
return lhs.equals(rhs);
108110
case RELATIONAL_OPERATOR_NOT_EQUALS:

span-processing-utils/src/test/java/org/hypertrace/config/span/processing/utils/SpanFilterMatcherTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ void testMatcher() {
3636
buildSpanFilterValue("names"),
3737
RelationalOperator.RELATIONAL_OPERATOR_CONTAINS));
3838

39+
assertFalse(
40+
this.spanFilterMatcher.matches(
41+
"name",
42+
buildSpanFilterValue("nam"),
43+
RelationalOperator.RELATIONAL_OPERATOR_NOT_CONTAINS));
44+
assertTrue(
45+
this.spanFilterMatcher.matches(
46+
"name",
47+
buildSpanFilterValue("names"),
48+
RelationalOperator.RELATIONAL_OPERATOR_NOT_CONTAINS));
49+
3950
assertTrue(
4051
this.spanFilterMatcher.matches(
4152
"name", buildSpanFilterValue("name"), RelationalOperator.RELATIONAL_OPERATOR_EQUALS));

0 commit comments

Comments
 (0)