mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
Fix rule evaluation closure.
This commit is contained in:
parent
5d65b9392a
commit
1eb586db7d
|
@ -17,6 +17,7 @@ import (
|
||||||
"github.com/prometheus/prometheus/config"
|
"github.com/prometheus/prometheus/config"
|
||||||
"github.com/prometheus/prometheus/rules/ast"
|
"github.com/prometheus/prometheus/rules/ast"
|
||||||
"log"
|
"log"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -66,15 +67,19 @@ func (m *ruleManager) Stop() {
|
||||||
|
|
||||||
func (m *ruleManager) runIteration(results chan *Result) {
|
func (m *ruleManager) runIteration(results chan *Result) {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
wg := sync.WaitGroup{}
|
||||||
for _, rule := range m.rules {
|
for _, rule := range m.rules {
|
||||||
go func() {
|
wg.Add(1)
|
||||||
|
go func(rule *Rule) {
|
||||||
vector, err := rule.Eval(&now)
|
vector, err := rule.Eval(&now)
|
||||||
m.results <- &Result{
|
m.results <- &Result{
|
||||||
Samples: vector,
|
Samples: vector,
|
||||||
Err: err,
|
Err: err,
|
||||||
}
|
}
|
||||||
}()
|
wg.Done()
|
||||||
|
}(rule)
|
||||||
}
|
}
|
||||||
|
wg.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ruleManager) AddRulesFromConfig(config *config.Config) error {
|
func (m *ruleManager) AddRulesFromConfig(config *config.Config) error {
|
||||||
|
|
Loading…
Reference in a new issue