[#1658] engine: Update metrics interfaces

It now supports typed object counter metrics.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2022-09-09 14:37:35 +03:00 committed by LeL
parent 175e2b9fa0
commit edef26a4fd
2 changed files with 10 additions and 10 deletions

View file

@ -17,8 +17,8 @@ type MetricRegister interface {
AddSearchDuration(d time.Duration)
AddListObjectsDuration(d time.Duration)
SetObjectCounter(shardID string, v uint64)
AddToObjectCounter(shardID string, delta int)
SetObjectCounter(shardID, objectType string, v uint64)
AddToObjectCounter(shardID, objectType string, delta int)
}
func elapsed(addFunc func(d time.Duration)) func() {

View file

@ -22,20 +22,20 @@ type metricsWithID struct {
mw MetricRegister
}
func (m metricsWithID) SetObjectCounter(v uint64) {
m.mw.SetObjectCounter(m.id, v)
func (m metricsWithID) SetObjectCounter(objectType string, v uint64) {
m.mw.SetObjectCounter(m.id, objectType, v)
}
func (m metricsWithID) AddToObjectCounter(delta int) {
m.mw.AddToObjectCounter(m.id, delta)
func (m metricsWithID) AddToObjectCounter(objectType string, delta int) {
m.mw.AddToObjectCounter(m.id, objectType, delta)
}
func (m metricsWithID) IncObjectCounter() {
m.mw.AddToObjectCounter(m.id, +1)
func (m metricsWithID) IncObjectCounter(objectType string) {
m.mw.AddToObjectCounter(m.id, objectType, +1)
}
func (m metricsWithID) DecObjectCounter() {
m.mw.AddToObjectCounter(m.id, -1)
func (m metricsWithID) DecObjectCounter(objectType string) {
m.mw.AddToObjectCounter(m.id, objectType, -1)
}
// AddShard adds a new shard to the storage engine.