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 } }