Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions upload/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@ var (
},
[]string{"code", "reason"},
)
uploadBytesTotal = promauto.With(registry).NewCounter(
uploadBytesTotal = promauto.With(registry).NewCounterVec(
prometheus.CounterOpts{
Name: "s3nd_upload_bytes_total",
Help: "number of bytes transferred for files which completed successfully",
Help: "the size of the upload request in bytes",
},
[]string{"code", "reason"},
)
s3HTTPResponsesTotal = promauto.With(registry).NewCounterVec(
prometheus.CounterOpts{
Expand Down Expand Up @@ -437,7 +438,6 @@ func (h *S3ndHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
case err == nil: // upload succeeded
code = http.StatusOK
msg = "upload succeeded"
uploadBytesTotal.Add(float64(task.UploadSizeBytes))
uploadTransferRateBytes.Observe(task.UploadTransferRateBytes)
case gherrors.As(err, &badRequestErr):
// bad request, e.g. missing required fields
Expand Down Expand Up @@ -472,7 +472,11 @@ func (h *S3ndHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
codeText := strconv.Itoa(code)
statusText := http.StatusText(code)

// counters
uploadRequestsTotal.WithLabelValues(codeText, statusText).Inc()
uploadBytesTotal.WithLabelValues(codeText, statusText).Add(float64(task.UploadSizeBytes))

// histogram
uploadTotalSeconds.WithLabelValues(codeText, statusText).Observe(task.UploadTotalSeconds)
uploadQueuedSeconds.WithLabelValues(codeText, statusText).Observe(task.UploadQueuedSeconds)
uploadTransferSeconds.WithLabelValues(codeText, statusText).Observe(task.UploadTransferSeconds)
Expand Down