Fix metric QueryCoordNumCollections (#24053)

Signed-off-by: longjiquan <jiquan.long@zilliz.com>
This commit is contained in:
Jiquan Long 2023-05-15 15:09:25 +08:00 committed by GitHub
parent 299561a242
commit 9eb78d5412
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 3 deletions

View File

@ -234,7 +234,6 @@ func (job *LoadCollectionJob) Execute() error {
return utils.WrapError(msg, err)
}
metrics.QueryCoordNumCollections.WithLabelValues().Inc()
return nil
}
@ -439,7 +438,6 @@ func (job *LoadPartitionJob) Execute() error {
return utils.WrapError(msg, err)
}
metrics.QueryCoordNumCollections.WithLabelValues().Inc()
return nil
}

View File

@ -223,6 +223,11 @@ func (ob *CollectionObserver) observeCollectionLoadStatus(collection *meta.Colle
ob.meta.CollectionManager.UpdateCollection(updated)
elapsed := time.Since(updated.CreatedAt)
// TODO: what if part of the collection has been unloaded? Now we decrease the metric only after
// `ReleaseCollection` is triggered. Maybe it's hard to make this metric really accurate.
metrics.QueryCoordNumCollections.WithLabelValues().Inc()
metrics.QueryCoordLoadLatency.WithLabelValues().Observe(float64(elapsed.Milliseconds()))
} else {
ob.meta.CollectionManager.UpdateCollectionInMemory(updated)

View File

@ -307,7 +307,9 @@ func (s *Server) initMeta() error {
log.Error("failed to recover collections")
return err
}
metrics.QueryCoordNumCollections.WithLabelValues().Set(float64(len(s.meta.GetAll())))
// We really update the metric after observers think the collection loaded.
metrics.QueryCoordNumCollections.WithLabelValues().Set(0)
err = s.meta.ReplicaManager.Recover(s.meta.CollectionManager.GetAll())
if err != nil {