- record access time

This commit is contained in:
gazebo
2019-01-09 15:08:27 +08:00
parent c0735d9d6c
commit bf35209354

View File

@@ -88,6 +88,7 @@ func AccessPlatformAPIWithRetry(client *http.Client, handleRequest func() *http.
if request.Body != nil {
request.Body = ioutil.NopCloser(io.TeeReader(request.Body, savedBuf))
}
beginTime := time.Now()
response, err := client.Do(request)
if err != nil {
baseapi.SugarLogger.Debugf("AccessPlatformAPIWithRetry client.Get return err:%v", err)
@@ -100,6 +101,10 @@ func AccessPlatformAPIWithRetry(client *http.Client, handleRequest func() *http.
return ErrAPIAccessFailed
}
}
usedMilliSecond := time.Now().Sub(beginTime) / time.Millisecond
if usedMilliSecond > 5000 {
baseapi.SugarLogger.Infof("AccessPlatformAPIWithRetry access api too slow, url:%v, request:%v, usedMilliSecond:%d", request.URL, getClonedData(savedBuf), usedMilliSecond)
}
defer response.Body.Close()
if response.StatusCode != 200 {
if bodyData, err := ioutil.ReadAll(response.Body); err == nil {