MCPcopy
hub / github.com/grafana/tempo / checkConditions

Function checkConditions

tempodb/encoding/vparquet4/block_traceql.go:1066–1120  ·  view source on GitHub ↗
(conditions []traceql.Condition)

Source from the content-addressed store, hash-verified

1064}
1065
1066func checkConditions(conditions []traceql.Condition) error {
1067 for _, cond := range conditions {
1068 opCount := len(cond.Operands)
1069
1070 switch cond.Op {
1071
1072 case traceql.OpNone, traceql.OpExists:
1073 if opCount != 0 {
1074 return fmt.Errorf("operation %v must have 0 arguments. condition: %+v", cond.Op, cond)
1075 }
1076
1077 case traceql.OpEqual, traceql.OpNotEqual,
1078 traceql.OpGreater, traceql.OpGreaterEqual,
1079 traceql.OpLess, traceql.OpLessEqual,
1080 traceql.OpRegex, traceql.OpNotRegex,
1081 traceql.OpIn, traceql.OpNotIn,
1082 traceql.OpRegexMatchAny, traceql.OpRegexMatchNone:
1083 if opCount != 1 {
1084 return fmt.Errorf("operation %v must have exactly 1 argument. condition: %+v", cond.Op, cond)
1085 }
1086
1087 case traceql.OpNotExists:
1088 if opCount != 0 {
1089 return fmt.Errorf("operation %v must have 0 arguments. condition: %+v", cond.Op, cond)
1090 }
1091 if cond.Attribute.Intrinsic != traceql.IntrinsicNone {
1092 return fmt.Errorf("intrinsics cannot be = nil")
1093 }
1094 if cond.Attribute == traceql.NewScopedAttribute(traceql.AttributeScopeResource, false, "service.name") {
1095 return fmt.Errorf("resource.service.name cannot be = nil")
1096 }
1097
1098 default:
1099 return fmt.Errorf("unknown operation. condition: %+v", cond)
1100 }
1101
1102 // Check for conditions that are not supported in vParquet4
1103 if cond.Attribute.Intrinsic == traceql.IntrinsicChildCount {
1104 return fmt.Errorf("intrinsic '%s' not supported in vParquet4: %w", cond.Attribute.Intrinsic, util.ErrUnsupported)
1105 }
1106
1107 // Verify all operands are of the same type
1108 if opCount == 0 {
1109 continue
1110 }
1111
1112 for i := 1; i < opCount; i++ {
1113 if reflect.TypeOf(cond.Operands[0]) != reflect.TypeOf(cond.Operands[i]) {
1114 return fmt.Errorf("operands must be of the same type. condition: %+v", cond)
1115 }
1116 }
1117 }
1118
1119 return nil
1120}
1121
1122func operandType(operands traceql.Operands) traceql.StaticType {
1123 if len(operands) > 0 {

Callers 6

FetchTagNamesMethod · 0.70
FetchTagValuesMethod · 0.70
FetchMethod · 0.70
FetchMethod · 0.70
FetchTagValuesMethod · 0.70
FetchTagNamesMethod · 0.70

Calls 1

NewScopedAttributeFunction · 0.92

Tested by

no test coverage detected