From f8f4ac14a86fae5e3e8cf912aadfed314cf4ee65 Mon Sep 17 00:00:00 2001 From: Alan Protasio Date: Wed, 14 Dec 2022 13:08:52 -0800 Subject: [PATCH 1/2] Finishing evalSpanTimer always before return Signed-off-by: Alan Protasio --- promql/engine.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/promql/engine.go b/promql/engine.go index a2b4384893..8dd76074c4 100644 --- a/promql/engine.go +++ b/promql/engine.go @@ -653,12 +653,12 @@ func (ng *Engine) execEvalStmt(ctx context.Context, query *query, s *parser.Eval query.sampleStats.InitStepTracking(start, start, 1) val, warnings, err := evaluator.Eval(s.Expr) + evalSpanTimer.Finish() + if err != nil { return nil, warnings, err } - evalSpanTimer.Finish() - var mat Matrix switch result := val.(type) { @@ -704,10 +704,12 @@ func (ng *Engine) execEvalStmt(ctx context.Context, query *query, s *parser.Eval } query.sampleStats.InitStepTracking(evaluator.startTimestamp, evaluator.endTimestamp, evaluator.interval) val, warnings, err := evaluator.Eval(s.Expr) + + evalSpanTimer.Finish() + if err != nil { return nil, warnings, err } - evalSpanTimer.Finish() mat, ok := val.(Matrix) if !ok { From 8460807475ad73592c5bb956f84aef024130be69 Mon Sep 17 00:00:00 2001 From: Alan Protasio Date: Wed, 14 Dec 2022 13:24:02 -0800 Subject: [PATCH 2/2] fix blank lines Signed-off-by: Alan Protasio --- promql/engine.go | 1 + 1 file changed, 1 insertion(+) diff --git a/promql/engine.go b/promql/engine.go index 8dd76074c4..b3ad14b3d7 100644 --- a/promql/engine.go +++ b/promql/engine.go @@ -653,6 +653,7 @@ func (ng *Engine) execEvalStmt(ctx context.Context, query *query, s *parser.Eval query.sampleStats.InitStepTracking(start, start, 1) val, warnings, err := evaluator.Eval(s.Expr) + evalSpanTimer.Finish() if err != nil {