(conditions []traceql.Condition)
| 1130 | } |
| 1131 | |
| 1132 | func checkConditions(conditions []traceql.Condition) error { |
| 1133 | for _, cond := range conditions { |
| 1134 | opCount := len(cond.Operands) |
| 1135 | |
| 1136 | switch cond.Op { |
| 1137 | |
| 1138 | case traceql.OpNone, traceql.OpExists: |
| 1139 | if opCount != 0 { |
| 1140 | return fmt.Errorf("operation %v must have 0 arguments. condition: %+v", cond.Op, cond) |
| 1141 | } |
| 1142 | |
| 1143 | case traceql.OpEqual, traceql.OpNotEqual, |
| 1144 | traceql.OpGreater, traceql.OpGreaterEqual, |
| 1145 | traceql.OpLess, traceql.OpLessEqual, |
| 1146 | traceql.OpRegex, traceql.OpNotRegex, |
| 1147 | traceql.OpIn, traceql.OpNotIn, |
| 1148 | traceql.OpRegexMatchAny, traceql.OpRegexMatchNone: |
| 1149 | if opCount != 1 { |
| 1150 | return fmt.Errorf("operation %v must have exactly 1 argument. condition: %+v", cond.Op, cond) |
| 1151 | } |
| 1152 | |
| 1153 | case traceql.OpNotExists: |
| 1154 | if opCount != 0 { |
| 1155 | return fmt.Errorf("operation %v must have 0 arguments. condition: %+v", cond.Op, cond) |
| 1156 | } |
| 1157 | if cond.Attribute.Intrinsic != traceql.IntrinsicNone { |
| 1158 | return fmt.Errorf("intrinsics cannot be = nil") |
| 1159 | } |
| 1160 | if cond.Attribute == traceql.NewScopedAttribute(traceql.AttributeScopeResource, false, "service.name") { |
| 1161 | return fmt.Errorf("resource.service.name cannot be = nil") |
| 1162 | } |
| 1163 | |
| 1164 | default: |
| 1165 | return fmt.Errorf("unknown operation. condition: %+v", cond) |
| 1166 | } |
| 1167 | |
| 1168 | // Verify all operands are of the same type |
| 1169 | if opCount == 0 { |
| 1170 | continue |
| 1171 | } |
| 1172 | |
| 1173 | for i := 1; i < opCount; i++ { |
| 1174 | if reflect.TypeOf(cond.Operands[0]) != reflect.TypeOf(cond.Operands[i]) { |
| 1175 | return fmt.Errorf("operands must be of the same type. condition: %+v", cond) |
| 1176 | } |
| 1177 | } |
| 1178 | } |
| 1179 | |
| 1180 | return nil |
| 1181 | } |
| 1182 | |
| 1183 | func operandType(operands traceql.Operands) traceql.StaticType { |
| 1184 | if len(operands) > 0 { |
no test coverage detected