Skip to content

Commit 1a520ea

Browse files
engine: dont merge in defer (#611)
Signed-off-by: Michael Hoffmann <[email protected]>
1 parent 91e6e32 commit 1a520ea

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

engine/engine.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -539,18 +539,15 @@ func (q *compatibilityQuery) Exec(ctx context.Context) (ret *promql.Result) {
539539
defer q.engine.activeQueryTracker.Delete(idx)
540540

541541
ctx = warnings.NewContext(ctx)
542-
defer func() {
543-
ret.Warnings = ret.Warnings.Merge(warnings.FromContext(ctx))
544-
}()
542+
warnings.MergeToContext(q.warns, ctx)
545543

546544
// Handle case with strings early on as this does not need us to process samples.
547545
switch e := q.plan.Root().(type) {
548546
case *logicalplan.StringLiteral:
549547
return &promql.Result{Value: promql.String{V: e.Val, T: q.ts.UnixMilli()}}
550548
}
551549
ret = &promql.Result{
552-
Value: promql.Vector{},
553-
Warnings: q.warns,
550+
Value: promql.Vector{},
554551
}
555552
defer recoverEngine(q.engine.logger, q.plan, &ret.Err)
556553

@@ -626,6 +623,7 @@ loop:
626623
}
627624
sort.Sort(matrix)
628625
ret.Value = matrix
626+
ret.Warnings = warnings.FromContext(ctx)
629627
if matrix.ContainsSameLabelset() {
630628
return newErrResult(ret, extlabels.ErrDuplicateLabelSet)
631629
}
@@ -679,6 +677,7 @@ loop:
679677
}
680678

681679
ret.Value = result
680+
ret.Warnings = warnings.FromContext(ctx)
682681
return ret
683682
}
684683

0 commit comments

Comments
 (0)