From 18762f82aa12cd77d7dad9130dfa44ee59643a58 Mon Sep 17 00:00:00 2001 From: yah01 Date: Wed, 30 Nov 2022 13:33:15 +0800 Subject: [PATCH] Refine TimeRecorder output (#20897) Signed-off-by: yah01 Signed-off-by: yah01 --- internal/util/timerecord/time_recorder.go | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/internal/util/timerecord/time_recorder.go b/internal/util/timerecord/time_recorder.go index 6061be3d56..4a640ecb14 100644 --- a/internal/util/timerecord/time_recorder.go +++ b/internal/util/timerecord/time_recorder.go @@ -14,10 +14,10 @@ package timerecord import ( "context" "fmt" - "strconv" "time" "github.com/milvus-io/milvus/internal/log" + "go.uber.org/zap" ) // TimeRecorder provides methods to record time duration @@ -80,15 +80,11 @@ func (tr *TimeRecorder) CtxElapse(ctx context.Context, msg string) time.Duration } func (tr *TimeRecorder) printTimeRecord(ctx context.Context, msg string, span time.Duration) { - str := "" - if tr.header != "" { - str += tr.header + ": " - } - str += msg - str += " (" - str += strconv.Itoa(int(span.Milliseconds())) - str += "ms)" - log.Ctx(ctx).Debug(str) + log.Ctx(ctx).WithOptions(zap.AddCallerSkip(2)). + Debug(fmt.Sprintf("timerecorder %s: record elapsed duration", tr.header), + zap.String("msg", msg), + zap.Duration("duration", span), + ) } // LongTermChecker checks we receive at least one msg in d duration. If not, checker