forked from TrueCloudLab/frostfs-node
[#1658] metrics: Add object counter metric
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
626766db08
commit
067ab44e0b
1 changed files with 20 additions and 0 deletions
|
@ -28,9 +28,13 @@ type (
|
||||||
|
|
||||||
putPayload prometheus.Counter
|
putPayload prometheus.Counter
|
||||||
getPayload prometheus.Counter
|
getPayload prometheus.Counter
|
||||||
|
|
||||||
|
shardMetrics *prometheus.GaugeVec
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const shardIDLabelKey = "shard"
|
||||||
|
|
||||||
func newObjectServiceMetrics() objectServiceMetrics {
|
func newObjectServiceMetrics() objectServiceMetrics {
|
||||||
var ( // Request counter metrics.
|
var ( // Request counter metrics.
|
||||||
getCounter = prometheus.NewCounter(prometheus.CounterOpts{
|
getCounter = prometheus.NewCounter(prometheus.CounterOpts{
|
||||||
|
@ -148,6 +152,15 @@ func newObjectServiceMetrics() objectServiceMetrics {
|
||||||
Name: "get_payload",
|
Name: "get_payload",
|
||||||
Help: "Accumulated payload size at object get method",
|
Help: "Accumulated payload size at object get method",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
shardsMetrics = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||||
|
Namespace: namespace,
|
||||||
|
Subsystem: objectSubsystem,
|
||||||
|
Name: "counter",
|
||||||
|
Help: "Objects counters per shards",
|
||||||
|
},
|
||||||
|
[]string{shardIDLabelKey},
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
return objectServiceMetrics{
|
return objectServiceMetrics{
|
||||||
|
@ -167,6 +180,7 @@ func newObjectServiceMetrics() objectServiceMetrics {
|
||||||
rangeHashDuration: rangeHashDuration,
|
rangeHashDuration: rangeHashDuration,
|
||||||
putPayload: putPayload,
|
putPayload: putPayload,
|
||||||
getPayload: getPayload,
|
getPayload: getPayload,
|
||||||
|
shardMetrics: shardsMetrics,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,6 +203,8 @@ func (m objectServiceMetrics) register() {
|
||||||
|
|
||||||
prometheus.MustRegister(m.putPayload)
|
prometheus.MustRegister(m.putPayload)
|
||||||
prometheus.MustRegister(m.getPayload)
|
prometheus.MustRegister(m.getPayload)
|
||||||
|
|
||||||
|
prometheus.MustRegister(m.shardMetrics)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m objectServiceMetrics) IncGetReqCounter() {
|
func (m objectServiceMetrics) IncGetReqCounter() {
|
||||||
|
@ -254,3 +270,7 @@ func (m objectServiceMetrics) AddPutPayload(ln int) {
|
||||||
func (m objectServiceMetrics) AddGetPayload(ln int) {
|
func (m objectServiceMetrics) AddGetPayload(ln int) {
|
||||||
m.getPayload.Add(float64(ln))
|
m.getPayload.Add(float64(ln))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m objectServiceMetrics) AddToObjectCounter(shardID string, delta int) {
|
||||||
|
m.shardMetrics.With(prometheus.Labels{shardIDLabelKey: shardID}).Add(float64(delta))
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue