mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
stats collect chunk upload retry count
This commit is contained in:
parent
726edab054
commit
df72dc206d
|
@ -31,6 +31,7 @@ type UploadResult struct {
|
||||||
Mime string `json:"mime,omitempty"`
|
Mime string `json:"mime,omitempty"`
|
||||||
Gzip uint32 `json:"gzip,omitempty"`
|
Gzip uint32 `json:"gzip,omitempty"`
|
||||||
ContentMd5 string `json:"contentMd5,omitempty"`
|
ContentMd5 string `json:"contentMd5,omitempty"`
|
||||||
|
RetryCount int `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (uploadResult *UploadResult) ToPbFileChunk(fileId string, offset int64) *filer_pb.FileChunk {
|
func (uploadResult *UploadResult) ToPbFileChunk(fileId string, offset int64) *filer_pb.FileChunk {
|
||||||
|
@ -94,6 +95,7 @@ func doUpload(uploadUrl string, filename string, cipher bool, reader io.Reader,
|
||||||
|
|
||||||
func retriedUploadData(uploadUrl string, filename string, cipher bool, data []byte, isInputCompressed bool, mtype string, pairMap map[string]string, jwt security.EncodedJwt) (uploadResult *UploadResult, err error) {
|
func retriedUploadData(uploadUrl string, filename string, cipher bool, data []byte, isInputCompressed bool, mtype string, pairMap map[string]string, jwt security.EncodedJwt) (uploadResult *UploadResult, err error) {
|
||||||
for i := 0; i < 3; i++ {
|
for i := 0; i < 3; i++ {
|
||||||
|
uploadResult.RetryCount = i
|
||||||
uploadResult, err = doUploadData(uploadUrl, filename, cipher, data, isInputCompressed, mtype, pairMap, jwt)
|
uploadResult, err = doUploadData(uploadUrl, filename, cipher, data, isInputCompressed, mtype, pairMap, jwt)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return
|
return
|
||||||
|
|
|
@ -38,10 +38,10 @@ func (fs *FilerServer) autoChunk(ctx context.Context, w http.ResponseWriter, r *
|
||||||
|
|
||||||
chunkSize := 1024 * 1024 * maxMB
|
chunkSize := 1024 * 1024 * maxMB
|
||||||
|
|
||||||
stats.FilerRequestCounter.WithLabelValues("postAutoChunk").Inc()
|
stats.FilerRequestCounter.WithLabelValues("chunk").Inc()
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
defer func() {
|
defer func() {
|
||||||
stats.FilerRequestHistogram.WithLabelValues("postAutoChunk").Observe(time.Since(start).Seconds())
|
stats.FilerRequestHistogram.WithLabelValues("chunk").Observe(time.Since(start).Seconds())
|
||||||
}()
|
}()
|
||||||
|
|
||||||
var reply *FilerPostResult
|
var reply *FilerPostResult
|
||||||
|
@ -302,13 +302,16 @@ func (fs *FilerServer) uploadReaderToChunks(w http.ResponseWriter, r *http.Reque
|
||||||
|
|
||||||
func (fs *FilerServer) doUpload(urlLocation string, w http.ResponseWriter, r *http.Request, limitedReader io.Reader, fileName string, contentType string, pairMap map[string]string, auth security.EncodedJwt) (*operation.UploadResult, error, []byte) {
|
func (fs *FilerServer) doUpload(urlLocation string, w http.ResponseWriter, r *http.Request, limitedReader io.Reader, fileName string, contentType string, pairMap map[string]string, auth security.EncodedJwt) (*operation.UploadResult, error, []byte) {
|
||||||
|
|
||||||
stats.FilerRequestCounter.WithLabelValues("postAutoChunkUpload").Inc()
|
stats.FilerRequestCounter.WithLabelValues("chunkUpload").Inc()
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
defer func() {
|
defer func() {
|
||||||
stats.FilerRequestHistogram.WithLabelValues("postAutoChunkUpload").Observe(time.Since(start).Seconds())
|
stats.FilerRequestHistogram.WithLabelValues("chunkUpload").Observe(time.Since(start).Seconds())
|
||||||
}()
|
}()
|
||||||
|
|
||||||
uploadResult, err, data := operation.Upload(urlLocation, fileName, fs.option.Cipher, limitedReader, false, contentType, pairMap, auth)
|
uploadResult, err, data := operation.Upload(urlLocation, fileName, fs.option.Cipher, limitedReader, false, contentType, pairMap, auth)
|
||||||
|
if uploadResult != nil && uploadResult.RetryCount > 0 {
|
||||||
|
stats.FilerRequestCounter.WithLabelValues("chunkUploadRetry").Add(float64(uploadResult.RetryCount))
|
||||||
|
}
|
||||||
return uploadResult, err, data
|
return uploadResult, err, data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue