From 7acc0cd2546899c179b5952710cba486d3200ee3 Mon Sep 17 00:00:00 2001 From: taytzehao Date: Wed, 20 Sep 2023 19:08:08 +0800 Subject: [PATCH] useTime duration calculation (#2651) Co-authored-by: tzehaoo Co-authored-by: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com> --- extra/redisotel/metrics.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/extra/redisotel/metrics.go b/extra/redisotel/metrics.go index fc44a14ca..915838f34 100644 --- a/extra/redisotel/metrics.go +++ b/extra/redisotel/metrics.go @@ -193,11 +193,13 @@ func (mh *metricsHook) DialHook(hook redis.DialHook) redis.DialHook { conn, err := hook(ctx, network, addr) + dur := time.Since(start) + attrs := make([]attribute.KeyValue, 0, len(mh.attrs)+1) attrs = append(attrs, mh.attrs...) attrs = append(attrs, statusAttr(err)) - mh.createTime.Record(ctx, milliseconds(time.Since(start)), metric.WithAttributes(attrs...)) + mh.createTime.Record(ctx, milliseconds(dur), metric.WithAttributes(attrs...)) return conn, err } }