Skip to content

Commit cb56037

Browse files
committed
refactor: change eval sleep
1 parent 2ebd64d commit cb56037

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

alert/eval/alert_rule.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ func (s *Scheduler) syncAlertRules() {
149149
for hash, rule := range alertRuleWorkers {
150150
if _, has := s.alertRules[hash]; !has {
151151
rule.Prepare()
152+
time.Sleep(time.Duration(20) * time.Millisecond)
152153
rule.Start()
153154
s.alertRules[hash] = rule
154155
}

alert/eval/eval.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
"github.com/ccfos/nightingale/v6/pkg/unit"
2626
"github.com/ccfos/nightingale/v6/prom"
2727
"github.com/prometheus/common/model"
28-
"golang.org/x/exp/rand"
2928

3029
"github.com/robfig/cron/v3"
3130
"github.com/toolkits/pkg/logger"
@@ -137,14 +136,11 @@ func (arw *AlertRuleWorker) Prepare() {
137136
}
138137

139138
func (arw *AlertRuleWorker) Start() {
140-
randomWait := time.Duration(rand.Intn(60000)) * time.Millisecond
141-
time.Sleep(randomWait)
142-
143-
logger.Infof("eval:%s started after waiting %d ms", arw.Key(), randomWait)
144139
arw.Scheduler.Start()
145140
}
146141

147142
func (arw *AlertRuleWorker) Eval() {
143+
logger.Infof("eval:%s started", arw.Key())
148144
if arw.Processor.PromEvalInterval == 0 {
149145
arw.Processor.PromEvalInterval = getPromEvalInterval(arw.Processor.ScheduleEntry.Schedule)
150146
}

0 commit comments

Comments
 (0)