refactor FilerRequest metrics (#3402)
* refactor FilerRequest metrics * avoid double count proxy * defer to
This commit is contained in:
committed by
GitHub
parent
bd13a7968f
commit
22181dd018
@@ -90,8 +90,11 @@ func (fs *FilerServer) uploadReaderToChunks(w http.ResponseWriter, r *http.Reque
|
||||
bufPool.Put(bytesBuffer)
|
||||
atomic.AddInt64(&bytesBufferCounter, -1)
|
||||
bytesBufferLimitCond.Signal()
|
||||
stats.FilerRequestCounter.WithLabelValues(stats.ContentSaveToFiler).Inc()
|
||||
break
|
||||
}
|
||||
} else {
|
||||
stats.FilerRequestCounter.WithLabelValues(stats.AutoChunk).Inc()
|
||||
}
|
||||
|
||||
wg.Add(1)
|
||||
@@ -138,10 +141,10 @@ func (fs *FilerServer) uploadReaderToChunks(w http.ResponseWriter, r *http.Reque
|
||||
|
||||
func (fs *FilerServer) doUpload(urlLocation string, limitedReader io.Reader, fileName string, contentType string, pairMap map[string]string, auth security.EncodedJwt) (*operation.UploadResult, error, []byte) {
|
||||
|
||||
stats.FilerRequestCounter.WithLabelValues("chunkUpload").Inc()
|
||||
stats.FilerRequestCounter.WithLabelValues(stats.ChunkUpload).Inc()
|
||||
start := time.Now()
|
||||
defer func() {
|
||||
stats.FilerRequestHistogram.WithLabelValues("chunkUpload").Observe(time.Since(start).Seconds())
|
||||
stats.FilerRequestHistogram.WithLabelValues(stats.ChunkUpload).Observe(time.Since(start).Seconds())
|
||||
}()
|
||||
|
||||
uploadOption := &operation.UploadOption{
|
||||
@@ -155,7 +158,7 @@ func (fs *FilerServer) doUpload(urlLocation string, limitedReader io.Reader, fil
|
||||
}
|
||||
uploadResult, err, data := operation.Upload(limitedReader, uploadOption)
|
||||
if uploadResult != nil && uploadResult.RetryCount > 0 {
|
||||
stats.FilerRequestCounter.WithLabelValues("chunkUploadRetry").Add(float64(uploadResult.RetryCount))
|
||||
stats.FilerRequestCounter.WithLabelValues(stats.ChunkUploadRetry).Add(float64(uploadResult.RetryCount))
|
||||
}
|
||||
return uploadResult, err, data
|
||||
}
|
||||
@@ -173,6 +176,7 @@ func (fs *FilerServer) dataToChunk(fileName, contentType string, data []byte, ch
|
||||
fileId, urlLocation, auth, uploadErr = fs.assignNewFileInfo(so)
|
||||
if uploadErr != nil {
|
||||
glog.V(4).Infof("retry later due to assign error: %v", uploadErr)
|
||||
stats.FilerRequestCounter.WithLabelValues(stats.ChunkAssignRetry).Inc()
|
||||
time.Sleep(time.Duration(i+1) * 251 * time.Millisecond)
|
||||
continue
|
||||
}
|
||||
@@ -181,6 +185,7 @@ func (fs *FilerServer) dataToChunk(fileName, contentType string, data []byte, ch
|
||||
uploadResult, uploadErr, _ = fs.doUpload(urlLocation, dataReader, fileName, contentType, nil, auth)
|
||||
if uploadErr != nil {
|
||||
glog.V(4).Infof("retry later due to upload error: %v", uploadErr)
|
||||
stats.FilerRequestCounter.WithLabelValues(stats.ChunkDoUploadRetry).Inc()
|
||||
time.Sleep(time.Duration(i+1) * 251 * time.Millisecond)
|
||||
continue
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user