Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions test/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ var _ = Describe("GET /metrics", func() {
"s3nd_upload_transfer_seconds",
"s3nd_upload_transfer_rate_bytes",
"s3nd_upload_transfer_size_bytes",
"s3nd_upload_attempts",
}

for _, m := range histogramMetrics {
Expand Down
12 changes: 12 additions & 0 deletions upload/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,17 @@ var (
},
[]string{"code", "reason"},
)
uploadAttempts = promauto.With(registry).NewHistogramVec(
prometheus.HistogramOpts{
Name: "s3nd_upload_attempts",
Help: "histogram of number of transfer attempts per file. Zero means the upload timed out while queued.",
NativeHistogramBucketFactor: 1.07, // expected range of 0-5 attempts
NativeHistogramZeroThreshold: 0.5, // only 0 in zero bucket
NativeHistogramMaxBucketNumber: 50,
NativeHistogramMinResetDuration: time.Hour,
},
[]string{"code", "reason"},
)
)

type S3ndHandler struct {
Expand Down Expand Up @@ -455,6 +466,7 @@ func (h *S3ndHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
uploadQueuedSeconds.WithLabelValues(codeText, statusText).Observe(task.UploadQueuedSeconds)
uploadTransferSeconds.WithLabelValues(codeText, statusText).Observe(task.UploadTransferSeconds)
uploadTransferSizeBytes.WithLabelValues(codeText, statusText).Observe(float64(task.UploadSizeBytes))
uploadAttempts.WithLabelValues(codeText, statusText).Observe(float64(task.UploadAttempts))
}

status := RequestStatus{
Expand Down