From 3f3614379070e5935b1c4f19516a467abc70dbb6 Mon Sep 17 00:00:00 2001 From: mlmhl Date: Sat, 26 Sep 2020 02:46:06 +0800 Subject: [PATCH] pkg/traceutil: skip subTraceStart/subTraceEnd steps when logging steps (#12262) SubTraceStart and SubTraceEnd steps are only placeholders, not really steps, we should skip them when logging the long duration steps, otherwise these steps will lead to incorrect start time and duration of subsequent steps. --- pkg/traceutil/trace.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/traceutil/trace.go b/pkg/traceutil/trace.go index cbe2cfbf0..680a35f47 100644 --- a/pkg/traceutil/trace.go +++ b/pkg/traceutil/trace.go @@ -192,6 +192,9 @@ func (t *Trace) logInfo(threshold time.Duration) (string, []zap.Field) { } for i := 0; i < len(t.steps); i++ { step := t.steps[i] + if step.isSubTraceStart || step.isSubTraceEnd { + continue + } stepDuration := step.time.Sub(lastStepTime) if stepDuration > threshold { steps = append(steps, fmt.Sprintf("trace[%d] '%v' %s (duration: %v)",