[#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

@ -56,6 +56,9 @@ type MetricsWriter interface {
// AddToContainerSize must add a value to the container size.
// Value can be negative.
AddToContainerSize(cnr string, value int64)
// AddToPayloadSize must add a value to the payload size.
// Value can be negative.
AddToPayloadSize(value int64)
// IncObjectCounter must increment shard's object counter taking into account
// object type.
IncObjectCounter(objectType string)
@ -346,6 +349,8 @@ func (s *Shard) updateMetrics() {
return
}
var totalPayload uint64
for i := range cnrList {
size, err := s.metaBase.ContainerSize(cnrList[i])
if err != nil {
@ -355,7 +360,10 @@ func (s *Shard) updateMetrics() {
continue
}
s.metricsWriter.AddToContainerSize(cnrList[i].EncodeToString(), int64(size))
totalPayload += size
}
s.metricsWriter.AddToPayloadSize(int64(totalPayload))
}
}
@ -379,3 +387,9 @@ func (s *Shard) addToContainerSize(cnr string, size int64) {
s.cfg.metricsWriter.AddToContainerSize(cnr, size)
}
}
func (s *Shard) addToPayloadCounter(size int64) {
if s.cfg.metricsWriter != nil {
s.cfg.metricsWriter.AddToPayloadSize(size)
}
}