Alerting: Add traceability headers for alert queries (#57127)

* Define EvaluationContext

* Refactor ConditionEval to use new context struct

* Refactor QueriesAndExpressionsEval to use EvaluationContext

* Remove dead field from AlertExecCtx

* Refactor Validate to use EvaluationContext

* Get rid of privately used AlertExecCtx

* Move EvaluationContext to new file and add helper

* Add builder pattern and bind rule info to context

* Extract header logic and add rule UID header

* Fix missing call
This commit is contained in:
Alexander Weaver
2022-10-19 14:19:43 -05:00
committed by GitHub
parent 85cda0db69
commit 4eb8e4ff66
8 changed files with 153 additions and 109 deletions
+2 -1
View File
@@ -445,8 +445,9 @@ func TestValidate(t *testing.T) {
condition := testCase.condition(cacheService)
evaluator := NewEvaluator(&setting.Cfg{ExpressionsEnabled: true}, log.New("test"), cacheService, expr.ProvideService(&setting.Cfg{ExpressionsEnabled: true}, nil, nil))
evalCtx := Context(context.Background(), u)
err := evaluator.Validate(context.Background(), u, condition)
err := evaluator.Validate(evalCtx, condition)
if testCase.error {
require.Error(t, err)
} else {