HTTP请求都打印访问耗时

This commit is contained in:
gazebo
2020-01-06 16:40:32 +08:00
parent 0de719a0ba
commit e0e9250b2f

View File

@@ -118,7 +118,8 @@ func AccessPlatformAPIWithRetry(client *http.Client, handleRequest func() *http.
trackInfo += ", " + utils.GetUUID()
baseapi.SugarLogger.Debugf("begin AccessPlatformAPIWithRetry:%s do:%s url:%v, request:%s", trackInfo, request.Method, request.URL, getClonedData(request.URL, savedBuf))
response, err := client.Do(request)
baseapi.SugarLogger.Debugf("end AccessPlatformAPIWithRetry:%s do:%s url:%v", trackInfo, request.Method, request.URL)
usedMilliSecond := time.Now().Sub(beginTime) / time.Millisecond
baseapi.SugarLogger.Debugf("end AccessPlatformAPIWithRetry:%s do:%s url:%v, usedMilliSecond:%d", trackInfo, request.Method, request.URL, usedMilliSecond)
if err != nil {
baseapi.SugarLogger.Debugf("AccessPlatformAPIWithRetry:%s client.Get return err:%v", trackInfo, err)
err, ok := err.(net.Error)
@@ -130,7 +131,6 @@ func AccessPlatformAPIWithRetry(client *http.Client, handleRequest func() *http.
return ErrAPIAccessFailed
}
}
usedMilliSecond := time.Now().Sub(beginTime) / time.Millisecond
if usedMilliSecond > 5000 {
baseapi.SugarLogger.Infof("AccessPlatformAPIWithRetry:%s access api too slow, url:%v, usedMilliSecond:%d", trackInfo, request.URL, usedMilliSecond)
}