rules: add evaluationTimestamp when copy state. (#7775)

Signed-off-by: johncming <johncming@yahoo.com>
This commit is contained in:
johncming 2020-08-14 16:42:13 +08:00 committed by GitHub
parent 5a7d398d19
commit 362080ba28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 0 deletions

View File

@ -500,6 +500,7 @@ func nameAndLabels(rule Rule) string {
// first is matched with the first, second with the second etc. // first is matched with the first, second with the second etc.
func (g *Group) CopyState(from *Group) { func (g *Group) CopyState(from *Group) {
g.evaluationDuration = from.evaluationDuration g.evaluationDuration = from.evaluationDuration
g.evaluationTimestamp = from.evaluationTimestamp
ruleMap := make(map[string][]int, len(from.rules)) ruleMap := make(map[string][]int, len(from.rules))

View File

@ -657,6 +657,7 @@ func TestCopyState(t *testing.T) {
testutil.Equals(t, want, newGroup.seriesInPreviousEval) testutil.Equals(t, want, newGroup.seriesInPreviousEval)
testutil.Equals(t, oldGroup.rules[0], newGroup.rules[3]) testutil.Equals(t, oldGroup.rules[0], newGroup.rules[3])
testutil.Equals(t, oldGroup.evaluationDuration, newGroup.evaluationDuration) 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) testutil.Equals(t, []labels.Labels{{{Name: "l1", Value: "v3"}}}, newGroup.staleSeries)
} }