From f4721c467f1cbc2da8ef5a4b613b96e92496fe4f Mon Sep 17 00:00:00 2001 From: Matthias Loibl Date: Fri, 2 Sep 2022 23:58:00 +0200 Subject: [PATCH] Remove thanos_ prefix from metrics Closes #23 --- objstore.go | 18 +++++++-------- objstore_test.go | 60 ++++++++++++++++++++++++------------------------ 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/objstore.go b/objstore.go index 9ba2ea2d..b7e0631c 100644 --- a/objstore.go +++ b/objstore.go @@ -45,7 +45,7 @@ type Bucket interface { Upload(ctx context.Context, name string, r io.Reader) error // Delete removes the object with the given name. - // If object does not exists in the moment of deletion, Delete should throw error. + // If object does not exist in the moment of deletion, Delete should throw error. Delete(ctx context.Context, name string) error // Name returns the bucket name for the provider. @@ -57,11 +57,11 @@ type InstrumentedBucket interface { Bucket // WithExpectedErrs allows to specify a filter that marks certain errors as expected, so it will not increment - // thanos_objstore_bucket_operation_failures_total metric. + // objstore_bucket_operation_failures_total metric. WithExpectedErrs(IsOpFailureExpectedFunc) Bucket // ReaderWithExpectedErrs allows to specify a filter that marks certain errors as expected, so it will not increment - // thanos_objstore_bucket_operation_failures_total metric. + // objstore_bucket_operation_failures_total metric. // TODO(bwplotka): Remove this when moved to Go 1.14 and replace with InstrumentedBucketReader. ReaderWithExpectedErrs(IsOpFailureExpectedFunc) BucketReader } @@ -94,7 +94,7 @@ type InstrumentedBucketReader interface { BucketReader // ReaderWithExpectedErrs allows to specify a filter that marks certain errors as expected, so it will not increment - // thanos_objstore_bucket_operation_failures_total metric. + // objstore_bucket_operation_failures_total metric. ReaderWithExpectedErrs(IsOpFailureExpectedFunc) BucketReader } @@ -392,7 +392,7 @@ func DownloadDir(ctx context.Context, logger log.Logger, bkt BucketReader, origi return nil } -// IsOpFailureExpectedFunc allows to mark certain errors as expected, so they will not increment thanos_objstore_bucket_operation_failures_total metric. +// IsOpFailureExpectedFunc allows to mark certain errors as expected, so they will not increment objstore_bucket_operation_failures_total metric. type IsOpFailureExpectedFunc func(error) bool var _ InstrumentedBucket = &metricBucket{} @@ -404,26 +404,26 @@ func BucketWithMetrics(name string, b Bucket, reg prometheus.Registerer) *metric bkt: b, isOpFailureExpected: func(err error) bool { return false }, ops: promauto.With(reg).NewCounterVec(prometheus.CounterOpts{ - Name: "thanos_objstore_bucket_operations_total", + Name: "objstore_bucket_operations_total", Help: "Total number of all attempted operations against a bucket.", ConstLabels: prometheus.Labels{"bucket": name}, }, []string{"operation"}), opsFailures: promauto.With(reg).NewCounterVec(prometheus.CounterOpts{ - Name: "thanos_objstore_bucket_operation_failures_total", + Name: "objstore_bucket_operation_failures_total", Help: "Total number of operations against a bucket that failed, but were not expected to fail in certain way from caller perspective. Those errors have to be investigated.", ConstLabels: prometheus.Labels{"bucket": name}, }, []string{"operation"}), opsDuration: promauto.With(reg).NewHistogramVec(prometheus.HistogramOpts{ - Name: "thanos_objstore_bucket_operation_duration_seconds", + Name: "objstore_bucket_operation_duration_seconds", Help: "Duration of successful operations against the bucket", ConstLabels: prometheus.Labels{"bucket": name}, Buckets: []float64{0.001, 0.01, 0.1, 0.3, 0.6, 1, 3, 6, 9, 20, 30, 60, 90, 120}, }, []string{"operation"}), lastSuccessfulUploadTime: promauto.With(reg).NewGaugeVec(prometheus.GaugeOpts{ - Name: "thanos_objstore_bucket_last_successful_upload_time", + Name: "objstore_bucket_last_successful_upload_time", Help: "Second timestamp of the last successful upload to the bucket.", }, []string{"bucket"}), } diff --git a/objstore_test.go b/objstore_test.go index 10ae005e..b51f0714 100644 --- a/objstore_test.go +++ b/objstore_test.go @@ -104,46 +104,46 @@ func TestDownloadUploadDirConcurrency(t *testing.T) { testutil.Ok(t, m.Upload(context.Background(), "dir/obj3", bytes.NewReader([]byte("3")))) testutil.Ok(t, promtest.GatherAndCompare(r, strings.NewReader(` - # HELP thanos_objstore_bucket_operations_total Total number of all attempted operations against a bucket. - # TYPE thanos_objstore_bucket_operations_total counter - thanos_objstore_bucket_operations_total{bucket="",operation="attributes"} 0 - thanos_objstore_bucket_operations_total{bucket="",operation="delete"} 0 - thanos_objstore_bucket_operations_total{bucket="",operation="exists"} 0 - thanos_objstore_bucket_operations_total{bucket="",operation="get"} 0 - thanos_objstore_bucket_operations_total{bucket="",operation="get_range"} 0 - thanos_objstore_bucket_operations_total{bucket="",operation="iter"} 0 - thanos_objstore_bucket_operations_total{bucket="",operation="upload"} 3 - `), `thanos_objstore_bucket_operations_total`)) + # HELP objstore_bucket_operations_total Total number of all attempted operations against a bucket. + # TYPE objstore_bucket_operations_total counter + objstore_bucket_operations_total{bucket="",operation="attributes"} 0 + objstore_bucket_operations_total{bucket="",operation="delete"} 0 + objstore_bucket_operations_total{bucket="",operation="exists"} 0 + objstore_bucket_operations_total{bucket="",operation="get"} 0 + objstore_bucket_operations_total{bucket="",operation="get_range"} 0 + objstore_bucket_operations_total{bucket="",operation="iter"} 0 + objstore_bucket_operations_total{bucket="",operation="upload"} 3 + `), `objstore_bucket_operations_total`)) testutil.Ok(t, DownloadDir(context.Background(), log.NewNopLogger(), m, "dir/", "dir/", tempDir, WithFetchConcurrency(10))) i, err := ioutil.ReadDir(tempDir) testutil.Ok(t, err) testutil.Assert(t, len(i) == 3) testutil.Ok(t, promtest.GatherAndCompare(r, strings.NewReader(` - # HELP thanos_objstore_bucket_operations_total Total number of all attempted operations against a bucket. - # TYPE thanos_objstore_bucket_operations_total counter - thanos_objstore_bucket_operations_total{bucket="",operation="attributes"} 0 - thanos_objstore_bucket_operations_total{bucket="",operation="delete"} 0 - thanos_objstore_bucket_operations_total{bucket="",operation="exists"} 0 - thanos_objstore_bucket_operations_total{bucket="",operation="get"} 3 - thanos_objstore_bucket_operations_total{bucket="",operation="get_range"} 0 - thanos_objstore_bucket_operations_total{bucket="",operation="iter"} 1 - thanos_objstore_bucket_operations_total{bucket="",operation="upload"} 3 - `), `thanos_objstore_bucket_operations_total`)) + # HELP objstore_bucket_operations_total Total number of all attempted operations against a bucket. + # TYPE objstore_bucket_operations_total counter + objstore_bucket_operations_total{bucket="",operation="attributes"} 0 + objstore_bucket_operations_total{bucket="",operation="delete"} 0 + objstore_bucket_operations_total{bucket="",operation="exists"} 0 + objstore_bucket_operations_total{bucket="",operation="get"} 3 + objstore_bucket_operations_total{bucket="",operation="get_range"} 0 + objstore_bucket_operations_total{bucket="",operation="iter"} 1 + objstore_bucket_operations_total{bucket="",operation="upload"} 3 + `), `objstore_bucket_operations_total`)) testutil.Ok(t, UploadDir(context.Background(), log.NewNopLogger(), m, tempDir, "/dir-copy", WithUploadConcurrency(10))) testutil.Ok(t, promtest.GatherAndCompare(r, strings.NewReader(` - # HELP thanos_objstore_bucket_operations_total Total number of all attempted operations against a bucket. - # TYPE thanos_objstore_bucket_operations_total counter - thanos_objstore_bucket_operations_total{bucket="",operation="attributes"} 0 - thanos_objstore_bucket_operations_total{bucket="",operation="delete"} 0 - thanos_objstore_bucket_operations_total{bucket="",operation="exists"} 0 - thanos_objstore_bucket_operations_total{bucket="",operation="get"} 3 - thanos_objstore_bucket_operations_total{bucket="",operation="get_range"} 0 - thanos_objstore_bucket_operations_total{bucket="",operation="iter"} 1 - thanos_objstore_bucket_operations_total{bucket="",operation="upload"} 6 - `), `thanos_objstore_bucket_operations_total`)) + # HELP objstore_bucket_operations_total Total number of all attempted operations against a bucket. + # TYPE objstore_bucket_operations_total counter + objstore_bucket_operations_total{bucket="",operation="attributes"} 0 + objstore_bucket_operations_total{bucket="",operation="delete"} 0 + objstore_bucket_operations_total{bucket="",operation="exists"} 0 + objstore_bucket_operations_total{bucket="",operation="get"} 3 + objstore_bucket_operations_total{bucket="",operation="get_range"} 0 + objstore_bucket_operations_total{bucket="",operation="iter"} 1 + objstore_bucket_operations_total{bucket="",operation="upload"} 6 + `), `objstore_bucket_operations_total`)) } func TestTimingTracingReader(t *testing.T) {