Alerting: Contextual log provider for rule key (#57476)

* create contextual log context provider
* use contextual provider in scheduler
* init logger in the package
* use context for log context
* use context in state manager
This commit is contained in:
Yuriy Tseretyan
2022-10-26 19:16:02 -04:00
committed by GitHub
parent 59ffd9571e
commit 0a4121cef8
9 changed files with 33 additions and 15 deletions

View File

@@ -306,7 +306,8 @@ func (sch *schedule) schedulePeriodic(ctx context.Context, t *ticker.T) error {
}
func (sch *schedule) ruleRoutine(grafanaCtx context.Context, key ngmodels.AlertRuleKey, evalCh <-chan *evaluation, updateCh <-chan ruleVersion) error {
logger := sch.log.New(key.LogContext()...)
grafanaCtx = ngmodels.WithRuleKey(grafanaCtx, key)
logger := sch.log.FromContext(grafanaCtx)
logger.Debug("Alert rule routine started")
orgID := fmt.Sprint(key.OrgID)