MCPcopy
hub / github.com/grafana/k6 / scanThresholdExpression

Function scanThresholdExpression

metrics/thresholds_parser.go:144–153  ·  view source on GitHub ↗

scanThresholdExpression scans a threshold condition expression of the form: `aggregation_method operator value`. An invalid or unknown operator will produce an error. However, no assertions regarding either the left-hand side aggregation method nor the right-hand side value will be made: they will b

(input string)

Source from the content-addressed store, hash-verified

142// side value will be made: they will be returned as is, only trimmed from
143// their spaces.
144func scanThresholdExpression(input string) (string, string, string, error) {
145 for _, op := range operatorTokens {
146 left, right, _ := strings.Cut(input, op)
147 if right != "" {
148 return strings.TrimSpace(left), op, strings.TrimSpace(right), nil
149 }
150 }
151
152 return "", "", "", fmt.Errorf("malformed threshold expression")
153}
154
155// Define accepted threshold expression aggregation tokens
156// Percentile token `p(..)` is accepted too but handled separately.

Callers 3

parseThresholdExpressionFunction · 0.85

Calls 1

ErrorfMethod · 0.80

Tested by 2

Used in the wild real call sites across dependent graphs

searching dependent graphs…