From 782e99810913b86e20429ad0f6bcff9cbbe82754 Mon Sep 17 00:00:00 2001 From: Evan Anderson Date: Thu, 24 Oct 2024 06:16:30 -0700 Subject: [PATCH] Propagate project and entity information to rule evaluation logs --- internal/engine/executor.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/internal/engine/executor.go b/internal/engine/executor.go index 6949f436b8..b4b467b341 100644 --- a/internal/engine/executor.go +++ b/internal/engine/executor.go @@ -78,12 +78,15 @@ func NewExecutor( // EvalEntityEvent evaluates the entity specified in the EntityInfoWrapper // against all relevant rules in the project hierarchy. func (e *executor) EvalEntityEvent(ctx context.Context, inf *entities.EntityInfoWrapper) error { - logger := zerolog.Ctx(ctx).Info(). + logger := zerolog.Ctx(ctx).With(). Str("entity_type", inf.Type.ToString()). Str("execution_id", inf.ExecutionID.String()). Str("provider_id", inf.ProviderID.String()). - Str("project_id", inf.ProjectID.String()) - logger.Msg("entity evaluation - started") + Str("project_id", inf.ProjectID.String()). + Logger() + logger.Info().Msg("entity evaluation - started") + // Propagate info to remaining log messages + ctx = logger.WithContext(ctx) // track the time taken to evaluate each entity entityStartTime := time.Now()