mirror of
https://github.com/prometheus/prometheus
synced 2024-12-27 17:13:22 +00:00
Merge pull request #156 from prometheus/julius-fix-rule-eval
Fix rule evaluation closure.
This commit is contained in:
commit
7f0165aabb
@ -17,6 +17,7 @@ import (
|
||||
"github.com/prometheus/prometheus/config"
|
||||
"github.com/prometheus/prometheus/rules/ast"
|
||||
"log"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -66,15 +67,19 @@ func (m *ruleManager) Stop() {
|
||||
|
||||
func (m *ruleManager) runIteration(results chan *Result) {
|
||||
now := time.Now()
|
||||
wg := sync.WaitGroup{}
|
||||
for _, rule := range m.rules {
|
||||
go func() {
|
||||
wg.Add(1)
|
||||
go func(rule *Rule) {
|
||||
vector, err := rule.Eval(&now)
|
||||
m.results <- &Result{
|
||||
Samples: vector,
|
||||
Err: err,
|
||||
}
|
||||
}()
|
||||
wg.Done()
|
||||
}(rule)
|
||||
}
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
func (m *ruleManager) AddRulesFromConfig(config *config.Config) error {
|
||||
|
Loading…
Reference in New Issue
Block a user