[#838] shard: Refactor `updateMetrics` method

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
feat/customer_objects_metric
Dmitrii Stepanov 2023-12-04 12:54:23 +03:00
parent b892feeaf6
commit 29550fe600
1 changed files with 44 additions and 42 deletions

View File

@ -398,7 +398,10 @@ const (
)
func (s *Shard) updateMetrics(ctx context.Context) {
if s.cfg.metricsWriter != nil && !s.GetMode().NoMetabase() {
if s.cfg.metricsWriter == nil || s.GetMode().NoMetabase() {
return
}
cc, err := s.metaBase.ObjectCounters()
if err != nil {
s.log.Warn(logs.ShardMetaObjectCounterRead,
@ -444,7 +447,6 @@ func (s *Shard) updateMetrics(ctx context.Context) {
for contID, count := range contCount.Logical {
s.metricsWriter.SetContainerObjectsCount(contID.EncodeToString(), logical, count)
}
}
}
// incObjectCounter increment both physical and logical object