Skip to content

Commit 073764c

Browse files
authored
Merge pull request #54 from lsst-dm/IT-6370/upload-attempts-histogram
add s3nd_upload_attempts histogram metric
2 parents f8b5ee0 + 6f31338 commit 073764c

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

test/metrics_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ var _ = Describe("GET /metrics", func() {
6868
"s3nd_upload_transfer_seconds",
6969
"s3nd_upload_transfer_rate_bytes",
7070
"s3nd_upload_transfer_size_bytes",
71+
"s3nd_upload_attempts",
7172
}
7273

7374
for _, m := range histogramMetrics {

upload/handler.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,17 @@ var (
141141
},
142142
[]string{"code", "reason"},
143143
)
144+
uploadAttempts = promauto.With(registry).NewHistogramVec(
145+
prometheus.HistogramOpts{
146+
Name: "s3nd_upload_attempts",
147+
Help: "histogram of number of transfer attempts per file. Zero means the upload timed out while queued.",
148+
NativeHistogramBucketFactor: 1.07, // expected range of 0-5 attempts
149+
NativeHistogramZeroThreshold: 0.5, // only 0 in zero bucket
150+
NativeHistogramMaxBucketNumber: 50,
151+
NativeHistogramMinResetDuration: time.Hour,
152+
},
153+
[]string{"code", "reason"},
154+
)
144155
)
145156

146157
type S3ndHandler struct {
@@ -455,6 +466,7 @@ func (h *S3ndHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
455466
uploadQueuedSeconds.WithLabelValues(codeText, statusText).Observe(task.UploadQueuedSeconds)
456467
uploadTransferSeconds.WithLabelValues(codeText, statusText).Observe(task.UploadTransferSeconds)
457468
uploadTransferSizeBytes.WithLabelValues(codeText, statusText).Observe(float64(task.UploadSizeBytes))
469+
uploadAttempts.WithLabelValues(codeText, statusText).Observe(float64(task.UploadAttempts))
458470
}
459471

460472
status := RequestStatus{

0 commit comments

Comments
 (0)