From a94ab259c66a956a078a18a7ed8a0576a68dfe72 Mon Sep 17 00:00:00 2001 From: Faye Lin <49775184+lingyufei@users.noreply.github.com> Date: Fri, 12 Apr 2024 23:46:14 +0800 Subject: [PATCH] Expression: Fix a bug of the display name of the threshold expression result (#85912) * replace ReferenceVar with RefID when creating the math command for the ThresholdCommand * Fix the Hysteresis test --- pkg/expr/hysteresis_test.go | 2 +- pkg/expr/threshold.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/expr/hysteresis_test.go b/pkg/expr/hysteresis_test.go index 49d75ac7c66..9a58a1a3492 100644 --- a/pkg/expr/hysteresis_test.go +++ b/pkg/expr/hysteresis_test.go @@ -15,7 +15,7 @@ import ( func TestHysteresisExecute(t *testing.T) { number := func(label string, value float64) mathexp.Number { - n := mathexp.NewNumber("A", data.Labels{"label": label}) + n := mathexp.NewNumber("B", data.Labels{"label": label}) n.SetValue(&value) return n } diff --git a/pkg/expr/threshold.go b/pkg/expr/threshold.go index b8991df2f94..6a1903f10cc 100644 --- a/pkg/expr/threshold.go +++ b/pkg/expr/threshold.go @@ -120,7 +120,7 @@ func (tc *ThresholdCommand) Execute(ctx context.Context, now time.Time, vars mat return mathexp.Results{}, err } - mathCommand, err := NewMathCommand(tc.ReferenceVar, mathExpression) + mathCommand, err := NewMathCommand(tc.RefID, mathExpression) if err != nil { return mathexp.Results{}, err }