diff --git a/pkg/storer/internal/transaction/metrics.go b/pkg/storer/internal/transaction/metrics.go index e3cc263715d..2b14f6f6708 100644 --- a/pkg/storer/internal/transaction/metrics.go +++ b/pkg/storer/internal/transaction/metrics.go @@ -10,8 +10,8 @@ import ( ) type metrics struct { - CommitCalls *prometheus.CounterVec - CommitDuration *prometheus.HistogramVec + MethodCalls *prometheus.CounterVec + MethodDuration *prometheus.HistogramVec } // newMetrics is a convenient constructor for creating new metrics. @@ -19,23 +19,23 @@ func newMetrics() metrics { const subsystem = "transaction" return metrics{ - CommitCalls: prometheus.NewCounterVec( + MethodCalls: prometheus.NewCounterVec( prometheus.CounterOpts{ Namespace: m.Namespace, Subsystem: subsystem, Name: "commit_calls", Help: "Number of commit calls.", }, - []string{"status"}, + []string{"method", "status"}, ), - CommitDuration: prometheus.NewHistogramVec( + MethodDuration: prometheus.NewHistogramVec( prometheus.HistogramOpts{ Namespace: m.Namespace, Subsystem: subsystem, Name: "commit_duration", Help: "The duration each commit call took.", }, - []string{"status"}, + []string{"method", "status"}, ), } } diff --git a/pkg/storer/internal/transaction/transaction.go b/pkg/storer/internal/transaction/transaction.go index 17f9bda9344..ec81e4ed736 100644 --- a/pkg/storer/internal/transaction/transaction.go +++ b/pkg/storer/internal/transaction/transaction.go @@ -20,6 +20,7 @@ import ( ) // TODO(esad): remove contexts from sharky and any other storage call +// TODO(esad): continue metrics /* The rules of the transction is as follows: @@ -208,11 +209,11 @@ func (t *transaction) Commit() (err error) { defer func(ti time.Time) { t.sharkyTrx.writtenLocs = nil // clear written locs so that the done callback does not remove them if err != nil { - t.metrics.CommitCalls.WithLabelValues("failure").Inc() - t.metrics.CommitDuration.WithLabelValues("failure").Observe(float64(time.Since(ti))) + t.metrics.MethodCalls.WithLabelValues("commit", "failure").Inc() + t.metrics.MethodDuration.WithLabelValues("commit", "failure").Observe(float64(time.Since(ti))) } else { - t.metrics.CommitCalls.WithLabelValues("success").Inc() - t.metrics.CommitDuration.WithLabelValues("success").Observe(float64(time.Since(ti))) + t.metrics.MethodCalls.WithLabelValues("commit", "success").Inc() + t.metrics.MethodDuration.WithLabelValues("commit", "success").Observe(float64(time.Since(ti))) } }(time.Now())