[#1794] metrics: Track physical object capacity per shard

Signed-off-by: Pavel Karpy <p.karpy@yadro.com>
This commit is contained in:
Pavel Karpy 2023-01-25 17:01:25 +03:00 committed by fyrchik
parent 9513f163aa
commit 89a0266f5e
7 changed files with 60 additions and 3 deletions

View file

@ -20,6 +20,7 @@ type (
searchDuration prometheus.Counter
listObjectsDuration prometheus.Counter
containerSize prometheus.GaugeVec
payloadSize prometheus.GaugeVec
}
)
@ -110,6 +111,13 @@ func newEngineMetrics() engineMetrics {
Name: "container_size",
Help: "Accumulated size of all objects in a container",
}, []string{containerIDLabelKey})
payloadSize = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: engineSubsystem,
Name: "payload_size",
Help: "Accumulated size of all objects in a shard",
}, []string{shardIDLabelKey})
)
return engineMetrics{
@ -125,6 +133,7 @@ func newEngineMetrics() engineMetrics {
searchDuration: searchDuration,
listObjectsDuration: listObjectsDuration,
containerSize: *containerSize,
payloadSize: *payloadSize,
}
}
@ -141,6 +150,7 @@ func (m engineMetrics) register() {
prometheus.MustRegister(m.searchDuration)
prometheus.MustRegister(m.listObjectsDuration)
prometheus.MustRegister(m.containerSize)
prometheus.MustRegister(m.payloadSize)
}
func (m engineMetrics) AddListContainersDuration(d time.Duration) {
@ -190,3 +200,7 @@ func (m engineMetrics) AddListObjectsDuration(d time.Duration) {
func (m engineMetrics) AddToContainerSize(cnrID string, size int64) {
m.containerSize.With(prometheus.Labels{containerIDLabelKey: cnrID}).Add(float64(size))
}
func (m engineMetrics) AddToPayloadCounter(shardID string, size int64) {
m.payloadSize.With(prometheus.Labels{shardIDLabelKey: shardID}).Add(float64(size))
}