Skip to content

Commit

Permalink
fix: make the entity num metric accurate
Browse files Browse the repository at this point in the history
Signed-off-by: yah01 <yang.cen@zilliz.com>
  • Loading branch information
yah01 committed Jan 5, 2024
1 parent 1c1f2a1 commit 889121d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
2 changes: 1 addition & 1 deletion internal/querynodev2/delegator/delegator_data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ func (s *DelegatorDataSuite) TestSyncTargetVersion() {
ms.EXPECT().Type().Return(segments.SegmentTypeGrowing)
ms.EXPECT().Collection().Return(1)
ms.EXPECT().Partition().Return(1)
ms.EXPECT().RowNum().Return(0)
ms.EXPECT().InsertCount().Return(0)
ms.EXPECT().Indexes().Return(nil)
ms.EXPECT().Shard().Return(s.vchannelName)
ms.EXPECT().Level().Return(datapb.SegmentLevel_L1)
Expand Down
35 changes: 16 additions & 19 deletions internal/querynodev2/segments/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,14 @@ func (mgr *segmentManager) Put(segmentType SegmentType, segments ...Segment) {
fmt.Sprint(len(segment.Indexes())),
segment.Level().String(),
).Inc()
if segment.RowNum() > 0 {
metrics.QueryNodeNumEntities.WithLabelValues(
fmt.Sprint(paramtable.GetNodeID()),
fmt.Sprint(segment.Collection()),
fmt.Sprint(segment.Partition()),
segment.Type().String(),
fmt.Sprint(len(segment.Indexes())),
).Add(float64(segment.RowNum()))
}

metrics.QueryNodeNumEntities.WithLabelValues(
fmt.Sprint(paramtable.GetNodeID()),
fmt.Sprint(segment.Collection()),
fmt.Sprint(segment.Partition()),
segment.Type().String(),
fmt.Sprint(len(segment.Indexes())),
).Add(float64(segment.InsertCount()))
}
mgr.updateMetric()

Expand Down Expand Up @@ -556,7 +555,6 @@ func (mgr *segmentManager) updateMetric() {
}

func remove(segment Segment) bool {
rowNum := segment.RowNum()
segment.Release()

metrics.QueryNodeNumSegments.WithLabelValues(
Expand All @@ -567,14 +565,13 @@ func remove(segment Segment) bool {
fmt.Sprint(len(segment.Indexes())),
segment.Level().String(),
).Dec()
if rowNum > 0 {
metrics.QueryNodeNumEntities.WithLabelValues(
fmt.Sprint(paramtable.GetNodeID()),
fmt.Sprint(segment.Collection()),
fmt.Sprint(segment.Partition()),
segment.Type().String(),
fmt.Sprint(len(segment.Indexes())),
).Sub(float64(rowNum))
}

metrics.QueryNodeNumEntities.WithLabelValues(
fmt.Sprint(paramtable.GetNodeID()),
fmt.Sprint(segment.Collection()),
fmt.Sprint(segment.Partition()),
segment.Type().String(),
fmt.Sprint(len(segment.Indexes())),
).Sub(float64(segment.InsertCount()))
return true
}

0 comments on commit 889121d

Please sign in to comment.