From 175e2b9fa0388d6e7e963fc348fc9a1d30fb845f Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Fri, 9 Sep 2022 12:47:07 +0300 Subject: [PATCH] [#1658] metrics: Add object type label to the counters It will allow to use labeled object counters, e.g.: "phy" for all the physically stored objects, "logic" for only available objects. Also, it will allow to add typed (regular, TS, SG, LOCK) counters if needed. Signed-off-by: Pavel Karpy --- pkg/metrics/object.go | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/pkg/metrics/object.go b/pkg/metrics/object.go index 5c4d2396..d343934c 100644 --- a/pkg/metrics/object.go +++ b/pkg/metrics/object.go @@ -33,7 +33,10 @@ type ( } ) -const shardIDLabelKey = "shard" +const ( + shardIDLabelKey = "shard" + counterTypeLabelKey = "type" +) func newObjectServiceMetrics() objectServiceMetrics { var ( // Request counter metrics. @@ -159,7 +162,7 @@ func newObjectServiceMetrics() objectServiceMetrics { Name: "counter", Help: "Objects counters per shards", }, - []string{shardIDLabelKey}, + []string{shardIDLabelKey, counterTypeLabelKey}, ) ) @@ -271,10 +274,20 @@ func (m objectServiceMetrics) AddGetPayload(ln int) { m.getPayload.Add(float64(ln)) } -func (m objectServiceMetrics) AddToObjectCounter(shardID string, delta int) { - m.shardMetrics.With(prometheus.Labels{shardIDLabelKey: shardID}).Add(float64(delta)) +func (m objectServiceMetrics) AddToObjectCounter(shardID, objectType string, delta int) { + m.shardMetrics.With( + prometheus.Labels{ + shardIDLabelKey: shardID, + counterTypeLabelKey: objectType, + }, + ).Add(float64(delta)) } -func (m objectServiceMetrics) SetObjectCounter(shardID string, v uint64) { - m.shardMetrics.With(prometheus.Labels{shardIDLabelKey: shardID}).Set(float64(v)) +func (m objectServiceMetrics) SetObjectCounter(shardID, objectType string, v uint64) { + m.shardMetrics.With( + prometheus.Labels{ + shardIDLabelKey: shardID, + counterTypeLabelKey: objectType, + }, + ).Set(float64(v)) }