diff --git a/internal/datacoord/meta.go b/internal/datacoord/meta.go index 156908ff3d..822bc9b049 100644 --- a/internal/datacoord/meta.go +++ b/internal/datacoord/meta.go @@ -466,11 +466,13 @@ func (m *meta) GetQuotaInfo() *metricsinfo.DataCoordQuotaMetrics { return info } -// GetCollectionIndexFilesSize returns the total index files size of all segment for each collection. -func (m *meta) GetCollectionIndexFilesSize() uint64 { +// SetStoredIndexFileSizeMetric returns the total index files size of all segment for each collection. +func (m *meta) SetStoredIndexFileSizeMetric() uint64 { m.RLock() defer m.RUnlock() var total uint64 + + metrics.DataCoordStoredIndexFilesSize.Reset() for _, segmentIdx := range m.indexMeta.GetAllSegIndexes() { coll, ok := m.collections[segmentIdx.CollectionID] if ok { diff --git a/internal/datacoord/meta_test.go b/internal/datacoord/meta_test.go index 2def53a5cc..6d5fb2c39e 100644 --- a/internal/datacoord/meta_test.go +++ b/internal/datacoord/meta_test.go @@ -604,7 +604,7 @@ func TestMeta_Basic(t *testing.T) { t.Run("Test GetCollectionBinlogSize", func(t *testing.T) { meta := createMeta(&datacoord.Catalog{}, withIndexMeta(createIndexMeta(&datacoord.Catalog{}))) - ret := meta.GetCollectionIndexFilesSize() + ret := meta.SetStoredIndexFileSizeMetric() assert.Equal(t, uint64(0), ret) meta.collections = map[UniqueID]*collectionInfo{ @@ -613,7 +613,7 @@ func TestMeta_Basic(t *testing.T) { DatabaseName: "db", }, } - ret = meta.GetCollectionIndexFilesSize() + ret = meta.SetStoredIndexFileSizeMetric() assert.Equal(t, uint64(11), ret) }) diff --git a/internal/datacoord/metrics_info.go b/internal/datacoord/metrics_info.go index 52d4dc65ac..03f0b9e552 100644 --- a/internal/datacoord/metrics_info.go +++ b/internal/datacoord/metrics_info.go @@ -40,7 +40,7 @@ import ( func (s *Server) getQuotaMetrics() *metricsinfo.DataCoordQuotaMetrics { info := s.meta.GetQuotaInfo() // Just generate the metrics data regularly - _ = s.meta.GetCollectionIndexFilesSize() + _ = s.meta.SetStoredIndexFileSizeMetric() return info }