forked from TrueCloudLab/frostfs-node
[#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 <carpawell@nspcc.ru>
This commit is contained in:
parent
a789159e5b
commit
175e2b9fa0
1 changed files with 19 additions and 6 deletions
|
@ -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))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue