mirror of https://github.com/milvus-io/milvus.git
enhance: add db label on binlog size metrics (#32003)
Signed-off-by: jaime <yun.zhang@zilliz.com>pull/32140/head
parent
1a98ce39f5
commit
d4fd6c7283
|
@ -269,8 +269,15 @@ func (m *meta) GetCollectionBinlogSize() (int64, map[UniqueID]int64) {
|
|||
if isSegmentHealthy(segment) && !segment.GetIsImporting() {
|
||||
total += segmentSize
|
||||
collectionBinlogSize[segment.GetCollectionID()] += segmentSize
|
||||
metrics.DataCoordStoredBinlogSize.WithLabelValues(
|
||||
fmt.Sprint(segment.GetCollectionID()), fmt.Sprint(segment.GetID())).Set(float64(segmentSize))
|
||||
|
||||
coll, ok := m.collections[segment.GetCollectionID()]
|
||||
if ok {
|
||||
metrics.DataCoordStoredBinlogSize.WithLabelValues(coll.DatabaseName,
|
||||
fmt.Sprint(segment.GetCollectionID()), fmt.Sprint(segment.GetID())).Set(float64(segmentSize))
|
||||
} else {
|
||||
log.Warn("not found database name", zap.Int64("collectionID", segment.GetCollectionID()))
|
||||
}
|
||||
|
||||
if _, ok := collectionRowsNum[segment.GetCollectionID()]; !ok {
|
||||
collectionRowsNum[segment.GetCollectionID()] = make(map[commonpb.SegmentState]int64)
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ import (
|
|||
"github.com/milvus-io/milvus/internal/proto/datapb"
|
||||
"github.com/milvus-io/milvus/pkg/common"
|
||||
"github.com/milvus-io/milvus/pkg/metrics"
|
||||
"github.com/milvus-io/milvus/pkg/util"
|
||||
"github.com/milvus-io/milvus/pkg/util/merr"
|
||||
"github.com/milvus-io/milvus/pkg/util/paramtable"
|
||||
"github.com/milvus-io/milvus/pkg/util/testutils"
|
||||
|
@ -400,6 +401,7 @@ func TestMeta_Basic(t *testing.T) {
|
|||
Schema: testSchema,
|
||||
Partitions: []UniqueID{partID0, partID1},
|
||||
StartPositions: []*commonpb.KeyDataPair{},
|
||||
DatabaseName: util.DefaultDBName,
|
||||
}
|
||||
collInfoWoPartition := &collectionInfo{
|
||||
ID: collID,
|
||||
|
@ -605,6 +607,12 @@ func TestMeta_Basic(t *testing.T) {
|
|||
assert.Len(t, collectionBinlogSize, 1)
|
||||
assert.Equal(t, int64(size0+size1), collectionBinlogSize[collID])
|
||||
assert.Equal(t, int64(size0+size1), total)
|
||||
|
||||
meta.collections[collID] = collInfo
|
||||
total, collectionBinlogSize = meta.GetCollectionBinlogSize()
|
||||
assert.Len(t, collectionBinlogSize, 1)
|
||||
assert.Equal(t, int64(size0+size1), collectionBinlogSize[collID])
|
||||
assert.Equal(t, int64(size0+size1), total)
|
||||
})
|
||||
|
||||
t.Run("Test AddAllocation", func(t *testing.T) {
|
||||
|
|
|
@ -135,6 +135,7 @@ var (
|
|||
Name: "stored_binlog_size",
|
||||
Help: "binlog size of healthy segments",
|
||||
}, []string{
|
||||
databaseLabelName,
|
||||
collectionIDLabelName,
|
||||
segmentIDLabelName,
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue