From 7bbab380b6374362e3fc055c9a754943b3614674 Mon Sep 17 00:00:00 2001 From: Marco Pracucci Date: Mon, 15 Mar 2021 15:05:47 +0100 Subject: [PATCH] Added tracing span to evaluator.eval() Signed-off-by: Marco Pracucci --- promql/engine.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/promql/engine.go b/promql/engine.go index 9fba6c68b..f963f454b 100644 --- a/promql/engine.go +++ b/promql/engine.go @@ -19,6 +19,7 @@ import ( "context" "fmt" "math" + "reflect" "regexp" "runtime" "sort" @@ -1125,6 +1126,10 @@ func (ev *evaluator) eval(expr parser.Expr) (parser.Value, storage.Warnings) { } numSteps := int((ev.endTimestamp-ev.startTimestamp)/ev.interval) + 1 + // Create a new span to help investigate inner evaluation performances. + span, _ := opentracing.StartSpanFromContext(ev.ctx, stats.InnerEvalTime.SpanOperation()+" eval "+reflect.TypeOf(expr).String()) + defer span.Finish() + switch e := expr.(type) { case *parser.AggregateExpr: unwrapParenExpr(&e.Param)