From 906a35bdbb672a8f609b1541fb87e3faf55a84f8 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Sat, 24 Feb 2024 01:07:18 +0200 Subject: [PATCH] lib/backup/actions: update vm_backups_uploaded_bytes_total metric along the file upload instead of after the file upload This solves two issues: 1. The vm_backups_uploaded_bytes_total metric will grow more smoothly 2. This prevents from int overflow at metrics.Counter.Add() when uploading files bigger than 2GiB --- lib/backup/actions/backup.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/backup/actions/backup.go b/lib/backup/actions/backup.go index 4ea9744128..28c8485800 100644 --- a/lib/backup/actions/backup.go +++ b/lib/backup/actions/backup.go @@ -170,7 +170,6 @@ func runBackup(src *fslocal.FS, dst common.RemoteFS, origin common.OriginFS, con prc := 100 * float64(n) / float64(uploadSize) logger.Infof("uploaded %d out of %d bytes (%.2f%%) from %s to %s in %s", n, uploadSize, prc, src, dst, elapsed) }) - bytesUploadedTotal.Add(int(bytesUploaded.Load())) if err != nil { return err } @@ -191,6 +190,7 @@ type statReader struct { func (sr *statReader) Read(p []byte) (int, error) { n, err := sr.r.Read(p) sr.bytesRead.Add(uint64(n)) + bytesUploadedTotal.Add(int(n)) return n, err }