From 8979d2ce808312ce2d41b62ac8a6c594f45cd468 Mon Sep 17 00:00:00 2001 From: lushenle Date: Thu, 19 Jun 2025 21:05:44 +0800 Subject: [PATCH] metric: treat io.EOF as successful upload, not an error Uploads that end with io.EOF are now considered successful and no longer increment the upload error metric. This aligns metric reporting with Go convention, where io.EOF indicates normal completion rather than an error. --- internal/metric/metric.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/metric/metric.go b/internal/metric/metric.go index 4e3e95d8..eb8fdbd6 100644 --- a/internal/metric/metric.go +++ b/internal/metric/metric.go @@ -18,6 +18,9 @@ package metric import ( + "errors" + "io" + "github.com/go-chi/chi/v5" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" @@ -648,7 +651,7 @@ func AddMetricsEndpoint(metricsPath string, handler chi.Router) { func TransferCompleted(bytesSent, bytesReceived int64, transferKind int, err error, isSFTPFs bool) { if transferKind == 0 { // upload - if err == nil { + if err == nil || errors.Is(err, io.EOF) { totalUploads.Inc() } else { totalUploadErrors.Inc()