Skip to content

Commit

Permalink
Remove thanos_ prefix from metrics
Browse files Browse the repository at this point in the history
Closes #23
  • Loading branch information
metalmatze committed Sep 2, 2022
1 parent a53cb72 commit f4721c4
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 39 deletions.
18 changes: 9 additions & 9 deletions objstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
}
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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{}
Expand All @@ -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"}),
}
Expand Down
60 changes: 30 additions & 30 deletions objstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit f4721c4

Please sign in to comment.