useTime duration calculation (#2651)

Co-authored-by: tzehaoo <tzehao@intnt.ai>
Co-authored-by: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com>
This commit is contained in:
taytzehao 2023-09-20 19:08:08 +08:00 committed by GitHub
parent e8ad794e96
commit 7acc0cd254
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

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