Skip to content

Commit

Permalink
enhance: Unify querycoord meta metrics (#38233)
Browse files Browse the repository at this point in the history
Related to #36456

Unify collection/partition number metrics to collection manager in case
of unwant missing modification

Signed-off-by: Congqi Xia <[email protected]>
  • Loading branch information
congqixia authored Dec 5, 2024
1 parent 7944538 commit 32645fc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 0 additions & 4 deletions internal/querycoordv2/job/job_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ func (job *ReleaseCollectionJob) Execute() error {
proxyutil.SetMsgType(commonpb.MsgType_ReleaseCollection))

waitCollectionReleased(job.dist, job.checkerController, req.GetCollectionID())
metrics.QueryCoordNumCollections.WithLabelValues().Dec()
metrics.QueryCoordNumPartitions.WithLabelValues().Sub(float64(len(toRelease)))
metrics.QueryCoordReleaseCount.WithLabelValues(metrics.TotalLabel).Inc()
metrics.QueryCoordReleaseCount.WithLabelValues(metrics.SuccessLabel).Inc()
return nil
Expand Down Expand Up @@ -196,7 +194,6 @@ func (job *ReleasePartitionJob) Execute() error {
log.Warn("failed to remove replicas", zap.Error(err))
}
job.targetObserver.ReleaseCollection(req.GetCollectionID())
metrics.QueryCoordNumCollections.WithLabelValues().Dec()
// try best discard cache
// shall not affect releasing if failed
job.proxyManager.InvalidateCollectionMetaCache(job.ctx,
Expand All @@ -216,6 +213,5 @@ func (job *ReleasePartitionJob) Execute() error {
job.targetObserver.ReleasePartition(req.GetCollectionID(), toRelease...)
waitCollectionReleased(job.dist, job.checkerController, req.GetCollectionID(), toRelease...)
}
metrics.QueryCoordNumPartitions.WithLabelValues().Sub(float64(len(toRelease)))
return nil
}
7 changes: 6 additions & 1 deletion internal/querycoordv2/meta/collection_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,7 @@ func (m *CollectionManager) UpdateLoadPercent(ctx context.Context, partitionID i
newCollection.RecoverTimes = 0

metrics.QueryCoordNumCollections.WithLabelValues().Set(float64(len(lo.Values(m.collections))))
metrics.QueryCoordNumPartitions.WithLabelValues().Set(float64(len(m.partitions)))
elapsed := time.Since(newCollection.CreatedAt)
metrics.QueryCoordLoadLatency.WithLabelValues().Observe(float64(elapsed.Milliseconds()))
eventlog.Record(eventlog.NewRawEvt(eventlog.Level_Info, fmt.Sprintf("Collection %d loaded", newCollection.CollectionID)))
Expand All @@ -616,6 +617,8 @@ func (m *CollectionManager) RemoveCollection(ctx context.Context, collectionID t
delete(m.collectionPartitions, collectionID)
}
metrics.CleanQueryCoordMetricsWithCollectionID(collectionID)
metrics.QueryCoordNumPartitions.WithLabelValues().Set(float64(len(m.partitions)))
metrics.QueryCoordNumCollections.WithLabelValues().Set(float64(len(lo.Values(m.collections))))
return nil
}

Expand All @@ -627,7 +630,9 @@ func (m *CollectionManager) RemovePartition(ctx context.Context, collectionID ty
m.rwmutex.Lock()
defer m.rwmutex.Unlock()

return m.removePartition(ctx, collectionID, partitionIDs...)
err := m.removePartition(ctx, collectionID, partitionIDs...)
metrics.QueryCoordNumPartitions.WithLabelValues().Set(float64(len(m.partitions)))
return err
}

func (m *CollectionManager) removePartition(ctx context.Context, collectionID typeutil.UniqueID, partitionIDs ...typeutil.UniqueID) error {
Expand Down

0 comments on commit 32645fc

Please sign in to comment.