From 362080ba283024a8dac0b74629cf030266b8d315 Mon Sep 17 00:00:00 2001 From: johncming Date: Fri, 14 Aug 2020 16:42:13 +0800 Subject: [PATCH] rules: add evaluationTimestamp when copy state. (#7775) Signed-off-by: johncming --- rules/manager.go | 1 + rules/manager_test.go | 1 + 2 files changed, 2 insertions(+) diff --git a/rules/manager.go b/rules/manager.go index 9e1661117..afc3afdb7 100644 --- a/rules/manager.go +++ b/rules/manager.go @@ -500,6 +500,7 @@ func nameAndLabels(rule Rule) string { // first is matched with the first, second with the second etc. func (g *Group) CopyState(from *Group) { g.evaluationDuration = from.evaluationDuration + g.evaluationTimestamp = from.evaluationTimestamp ruleMap := make(map[string][]int, len(from.rules)) diff --git a/rules/manager_test.go b/rules/manager_test.go index 419b42834..e9deb70ad 100644 --- a/rules/manager_test.go +++ b/rules/manager_test.go @@ -657,6 +657,7 @@ func TestCopyState(t *testing.T) { testutil.Equals(t, want, newGroup.seriesInPreviousEval) testutil.Equals(t, oldGroup.rules[0], newGroup.rules[3]) testutil.Equals(t, oldGroup.evaluationDuration, newGroup.evaluationDuration) + testutil.Equals(t, oldGroup.evaluationTimestamp, newGroup.evaluationTimestamp) testutil.Equals(t, []labels.Labels{{{Name: "l1", Value: "v3"}}}, newGroup.staleSeries) }