From 25a6c5ad5588787c716c547f5915a4a224b2d7b4 Mon Sep 17 00:00:00 2001 From: Christian Simon Date: Thu, 27 Jul 2023 10:17:54 +0100 Subject: [PATCH] Only register fetched_bytes metrics for Get/GetRange The other operations are not exposing the fetched bytes. Signed-off-by: Christian Simon --- objstore.go | 5 +++++ objstore_test.go | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/objstore.go b/objstore.go index 2a0fe4dc..783c16f9 100644 --- a/objstore.go +++ b/objstore.go @@ -455,6 +455,11 @@ func WrapWithMetrics(b Bucket, reg prometheus.Registerer, name string) *metricBu bkt.ops.WithLabelValues(op) bkt.opsFailures.WithLabelValues(op) bkt.opsDuration.WithLabelValues(op) + } + for _, op := range []string{ + OpGet, + OpGetRange, + } { bkt.opsFetchedBytes.WithLabelValues(op) } // fetched bytes only relevant for get and getrange diff --git a/objstore_test.go b/objstore_test.go index ab5c5e5b..e27bfd80 100644 --- a/objstore_test.go +++ b/objstore_test.go @@ -112,13 +112,8 @@ func TestDownloadUploadDirConcurrency(t *testing.T) { testutil.Ok(t, promtest.GatherAndCompare(r, strings.NewReader(` # HELP objstore_bucket_operation_fetched_bytes_total Total number of bytes fetched from bucket, per operation. # TYPE objstore_bucket_operation_fetched_bytes_total counter - objstore_bucket_operation_fetched_bytes_total{bucket="",operation="attributes"} 0 - objstore_bucket_operation_fetched_bytes_total{bucket="",operation="delete"} 0 - objstore_bucket_operation_fetched_bytes_total{bucket="",operation="exists"} 0 objstore_bucket_operation_fetched_bytes_total{bucket="",operation="get"} 1.048578e+06 objstore_bucket_operation_fetched_bytes_total{bucket="",operation="get_range"} 0 - objstore_bucket_operation_fetched_bytes_total{bucket="",operation="iter"} 0 - objstore_bucket_operation_fetched_bytes_total{bucket="",operation="upload"} 0 `), `objstore_bucket_operation_fetched_bytes_total`)) testutil.Ok(t, promtest.GatherAndCompare(r, strings.NewReader(`