diff --git a/promql/engine.go b/promql/engine.go index 375c22d56..637cf40ec 100644 --- a/promql/engine.go +++ b/promql/engine.go @@ -51,10 +51,10 @@ type Value interface { String() string } -func (Matrix) Type() ValueType { return ValueTypeMatrix } -func (Vector) Type() ValueType { return ValueTypeVector } -func (Scalar) Type() ValueType { return ValueTypeScalar } -func (stringVal) Type() ValueType { return ValueTypeString } +func (Matrix) Type() ValueType { return ValueTypeMatrix } +func (Vector) Type() ValueType { return ValueTypeVector } +func (Scalar) Type() ValueType { return ValueTypeScalar } +func (String) Type() ValueType { return ValueTypeString } // ValueType describes a type of a value. type ValueType string @@ -68,13 +68,13 @@ const ( ValueTypeString = "string" ) -type stringVal struct { - s string - t int64 +type String struct { + V string + T int64 } -func (s stringVal) String() string { - return s.s +func (s String) String() string { + return s.V } // Scalar is a data point that's explicitly not associated with a metric. @@ -678,9 +678,9 @@ func (ev *evaluator) evalMatrix(e Expr) Matrix { } // evalString attempts to evaluate e to a string value and errors otherwise. -func (ev *evaluator) evalString(e Expr) stringVal { +func (ev *evaluator) evalString(e Expr) String { val := ev.eval(e) - sv, ok := val.(stringVal) + sv, ok := val.(String) if !ok { ev.errorf("expected string but got %s", documentedType(val.Type())) } @@ -756,7 +756,7 @@ func (ev *evaluator) eval(expr Expr) Value { return ev.eval(e.Expr) case *StringLiteral: - return stringVal{s: e.Val, t: ev.Timestamp} + return String{V: e.Val, T: ev.Timestamp} case *UnaryExpr: se := ev.evalOneOf(e.Expr, ValueTypeScalar, ValueTypeVector) @@ -1259,7 +1259,7 @@ func (ev *evaluator) aggregation(op itemType, grouping []string, without bool, k } var valueLabel string if op == itemCountValues { - valueLabel = ev.evalString(param).s + valueLabel = ev.evalString(param).V if !without { grouping = append(grouping, valueLabel) } diff --git a/promql/functions.go b/promql/functions.go index 800623a76..271f8a870 100644 --- a/promql/functions.go +++ b/promql/functions.go @@ -788,10 +788,10 @@ func funcChanges(ev *evaluator, args Expressions) Value { func funcLabelReplace(ev *evaluator, args Expressions) Value { var ( Vector = ev.evalVector(args[0]) - dst = ev.evalString(args[1]).s - repl = ev.evalString(args[2]).s - src = ev.evalString(args[3]).s - regexStr = ev.evalString(args[4]).s + dst = ev.evalString(args[1]).V + repl = ev.evalString(args[2]).V + src = ev.evalString(args[3]).V + regexStr = ev.evalString(args[4]).V ) regex, err := regexp.Compile("^(?:" + regexStr + ")$")