Skip to content

Commit

Permalink
Use Promauto (grafana#3263)
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Pivotto <[email protected]>
  • Loading branch information
roidelapluie authored Oct 13, 2020
1 parent bf42c68 commit aed2469
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions table_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/go-kit/kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prometheus/common/model"
tsdberrors "github.com/prometheus/prometheus/tsdb/errors"
"github.com/weaveworks/common/instrument"
Expand All @@ -38,46 +39,36 @@ type tableManagerMetrics struct {

func newTableManagerMetrics(r prometheus.Registerer) *tableManagerMetrics {
m := tableManagerMetrics{}
m.syncTableDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{
m.syncTableDuration = promauto.With(r).NewHistogramVec(prometheus.HistogramOpts{
Namespace: "cortex",
Name: "table_manager_sync_duration_seconds",
Help: "Time spent synching tables.",
Buckets: prometheus.DefBuckets,
}, []string{"operation", "status_code"})

m.tableCapacity = prometheus.NewGaugeVec(prometheus.GaugeOpts{
m.tableCapacity = promauto.With(r).NewGaugeVec(prometheus.GaugeOpts{
Namespace: "cortex",
Name: "table_capacity_units",
Help: "Per-table capacity, measured in DynamoDB capacity units.",
}, []string{"op", "table"})

m.createFailures = prometheus.NewGauge(prometheus.GaugeOpts{
m.createFailures = promauto.With(r).NewGauge(prometheus.GaugeOpts{
Namespace: "cortex",
Name: "table_manager_create_failures",
Help: "Number of table creation failures during the last table-manager reconciliation",
})
m.deleteFailures = prometheus.NewGauge(prometheus.GaugeOpts{
m.deleteFailures = promauto.With(r).NewGauge(prometheus.GaugeOpts{
Namespace: "cortex",
Name: "table_manager_delete_failures",
Help: "Number of table deletion failures during the last table-manager reconciliation",
})

m.lastSuccessfulSync = prometheus.NewGauge(prometheus.GaugeOpts{
m.lastSuccessfulSync = promauto.With(r).NewGauge(prometheus.GaugeOpts{
Namespace: "cortex",
Name: "table_manager_sync_success_timestamp_seconds",
Help: "Timestamp of the last successful table manager sync.",
})

if r != nil {
r.MustRegister(
m.syncTableDuration,
m.tableCapacity,
m.createFailures,
m.deleteFailures,
m.lastSuccessfulSync,
)
}

return &m
}

Expand Down

0 comments on commit aed2469

Please sign in to comment.