Alerting: Add context.Context to RuleStore (#45004)

Alerting: Add context.Context to RuleStore
This commit is contained in:
George Robinson
2022-02-08 08:52:03 +00:00
committed by GitHub
parent 31ba5bfea0
commit a9399ab3cd
13 changed files with 108 additions and 96 deletions
+3 -2
View File
@@ -1,12 +1,13 @@
package schedule
import (
"context"
"time"
"github.com/grafana/grafana/pkg/services/ngalert/models"
)
func (sch *schedule) getAlertRules(disabledOrgs []int64) []*models.AlertRule {
func (sch *schedule) getAlertRules(ctx context.Context, disabledOrgs []int64) []*models.AlertRule {
start := time.Now()
defer func() {
sch.metrics.GetAlertRulesDuration.Observe(time.Since(start).Seconds())
@@ -15,7 +16,7 @@ func (sch *schedule) getAlertRules(disabledOrgs []int64) []*models.AlertRule {
q := models.ListAlertRulesQuery{
ExcludeOrgs: disabledOrgs,
}
err := sch.ruleStore.GetAlertRulesForScheduling(&q)
err := sch.ruleStore.GetAlertRulesForScheduling(ctx, &q)
if err != nil {
sch.log.Error("failed to fetch alert definitions", "err", err)
return nil