[#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
|
||||
getPayload prometheus.Counter
|
||||
|
||||
shardMetrics *prometheus.GaugeVec
|
||||
}
|
||||
)
|
||||
|
||||
const shardIDLabelKey = "shard"
|
||||
|
||||
func newObjectServiceMetrics() objectServiceMetrics {
|
||||
var ( // Request counter metrics.
|
||||
getCounter = prometheus.NewCounter(prometheus.CounterOpts{
|
||||
|
@ -148,6 +152,15 @@ func newObjectServiceMetrics() objectServiceMetrics {
|
|||
Name: "get_payload",
|
||||
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{
|
||||
|
@ -167,6 +180,7 @@ func newObjectServiceMetrics() objectServiceMetrics {
|
|||
rangeHashDuration: rangeHashDuration,
|
||||
putPayload: putPayload,
|
||||
getPayload: getPayload,
|
||||
shardMetrics: shardsMetrics,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -189,6 +203,8 @@ func (m objectServiceMetrics) register() {
|
|||
|
||||
prometheus.MustRegister(m.putPayload)
|
||||
prometheus.MustRegister(m.getPayload)
|
||||
|
||||
prometheus.MustRegister(m.shardMetrics)
|
||||
}
|
||||
|
||||
func (m objectServiceMetrics) IncGetReqCounter() {
|
||||
|
@ -254,3 +270,7 @@ func (m objectServiceMetrics) AddPutPayload(ln int) {
|
|||
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))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue