1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-03-17 21:07:54 +02:00

protect slice bounds not out of range (#282)

This commit is contained in:
zhangji 2019-08-26 23:33:22 +08:00 committed by Felix Hao
parent 5a6d1e01b0
commit 2c6eb487a3

View File

@ -34,8 +34,10 @@ func Logger() HandlerFunc {
caller = noUser
}
_metricServerReqCodeTotal.Inc(c.RoutePath[1:], caller, strconv.FormatInt(int64(cerr.Code()), 10))
_metricServerReqDur.Observe(int64(dt/time.Millisecond), c.RoutePath[1:], caller)
if len(c.RoutePath) > 0 {
_metricServerReqCodeTotal.Inc(c.RoutePath[1:], caller, strconv.FormatInt(int64(cerr.Code()), 10))
_metricServerReqDur.Observe(int64(dt/time.Millisecond), c.RoutePath[1:], caller)
}
lf := log.Infov
errmsg := ""