mirror of
https://github.com/drakkan/sftpgo.git
synced 2026-03-14 22:35:52 +01:00
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.
This commit is contained in:
parent
cea5dd665e
commit
8979d2ce80
1 changed files with 4 additions and 1 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue