From a3f7bb5f2d0e8bf0d7f495772ba2b3b9ae8916d1 Mon Sep 17 00:00:00 2001 From: "zhenshan.cao" Date: Tue, 26 Apr 2022 17:29:45 +0800 Subject: [PATCH] Remove the collectionID label from metrics (#16571) Signed-off-by: zhenshan.cao --- internal/metrics/rootcoord_metrics.go | 16 ++++++++-------- internal/proxy/task.go | 1 - internal/rootcoord/root_coord.go | 17 ++++------------- internal/rootcoord/task.go | 5 ----- 4 files changed, 12 insertions(+), 27 deletions(-) diff --git a/internal/metrics/rootcoord_metrics.go b/internal/metrics/rootcoord_metrics.go index 155ba8676d..9939cfb780 100644 --- a/internal/metrics/rootcoord_metrics.go +++ b/internal/metrics/rootcoord_metrics.go @@ -297,8 +297,8 @@ var ( Namespace: milvusNamespace, Subsystem: typeutil.RootCoordRole, Name: "num_of_partitions", - Help: "The number of partitions per collection", - }, []string{collectionIDLabelName}) + Help: "The number of partitions", + }, []string{}) // RootCoordNumOfSegments counts the number of segments per collections. RootCoordNumOfSegments = prometheus.NewGaugeVec( @@ -306,8 +306,8 @@ var ( Namespace: milvusNamespace, Subsystem: typeutil.RootCoordRole, Name: "num_of_segments", - Help: "The number of segments per collection", - }, []string{collectionIDLabelName}) + Help: "The number of segments", + }, []string{}) // RootCoordNumOfIndexedSegments counts the number of indexed segments per collection. RootCoordNumOfIndexedSegments = prometheus.NewGaugeVec( @@ -315,8 +315,8 @@ var ( Namespace: milvusNamespace, Subsystem: typeutil.RootCoordRole, Name: "num_of_indexed_segments", - Help: "The number of indexed segments per collection", - }, []string{collectionIDLabelName}) + Help: "The number of indexed segments", + }, []string{}) // RootCoordNumOfDMLChannel counts the number of DML channels. RootCoordNumOfDMLChannel = prometheus.NewGauge( @@ -384,8 +384,8 @@ func RegisterRootCoord(registry *prometheus.Registry) { // for collection registry.MustRegister(RootCoordNumOfCollections) registry.MustRegister(RootCoordNumOfPartitions) - registry.MustRegister(RootCoordNumOfSegments) - registry.MustRegister(RootCoordNumOfIndexedSegments) + // registry.MustRegister(RootCoordNumOfSegments) + // registry.MustRegister(RootCoordNumOfIndexedSegments) registry.MustRegister(RootCoordNumOfDMLChannel) registry.MustRegister(RootCoordNumOfMsgStream) diff --git a/internal/proxy/task.go b/internal/proxy/task.go index 6a416f2409..7062af1dc7 100644 --- a/internal/proxy/task.go +++ b/internal/proxy/task.go @@ -777,7 +777,6 @@ func (dct *dropCollectionTask) Execute(ctx context.Context) error { _ = dct.chMgr.removeDMLStream(collID) _ = dct.chMgr.removeDQLStream(collID) - return nil } diff --git a/internal/rootcoord/root_coord.go b/internal/rootcoord/root_coord.go index 59429b5fd7..3a77f2ba64 100644 --- a/internal/rootcoord/root_coord.go +++ b/internal/rootcoord/root_coord.go @@ -77,14 +77,6 @@ type DdOperation struct { Type string `json:"type"` } -const ( - // MetricRequestsTotal used to count the num of total requests - MetricRequestsTotal = "total" - - // MetricRequestsSuccess used to count the num of successful requests - MetricRequestsSuccess = "success" -) - func metricProxy(v int64) string { return fmt.Sprintf("client_%d", v) } @@ -467,7 +459,6 @@ func (c *Core) getSegments(ctx context.Context, collID typeutil.UniqueID) (map[t } } - metrics.RootCoordNumOfSegments.WithLabelValues(strconv.FormatInt(collID, 10)).Set(float64(len(segID2PartID))) return segID2PartID, nil } @@ -1534,7 +1525,7 @@ func (c *Core) DescribeCollection(ctx context.Context, in *milvuspb.DescribeColl // ShowCollections list all collection names func (c *Core) ShowCollections(ctx context.Context, in *milvuspb.ShowCollectionsRequest) (*milvuspb.ShowCollectionsResponse, error) { - metrics.RootCoordShowCollectionsCounter.WithLabelValues(MetricRequestsTotal).Inc() + metrics.RootCoordShowCollectionsCounter.WithLabelValues(metrics.TotalLabel).Inc() if code, ok := c.checkHealthy(); !ok { return &milvuspb.ShowCollectionsResponse{ Status: failStatus(commonpb.ErrorCode_UnexpectedError, "StateCode="+internalpb.StateCode_name[int32(code)]), @@ -1564,7 +1555,7 @@ func (c *Core) ShowCollections(ctx context.Context, in *milvuspb.ShowCollections zap.String("dbname", in.DbName), zap.Int("num of collections", len(t.Rsp.CollectionNames)), zap.Int64("msgID", in.Base.MsgID)) - metrics.RootCoordShowCollectionsCounter.WithLabelValues(MetricRequestsSuccess).Inc() + metrics.RootCoordShowCollectionsCounter.WithLabelValues(metrics.SuccessLabel).Inc() t.Rsp.Status = succStatus() metrics.RootCoordDDLReadTypeLatency.WithLabelValues("ShowCollections").Observe(float64(tr.ElapseSpan().Milliseconds())) return t.Rsp, nil @@ -1600,7 +1591,7 @@ func (c *Core) CreatePartition(ctx context.Context, in *milvuspb.CreatePartition metrics.RootCoordCreatePartitionCounter.WithLabelValues(metrics.SuccessLabel).Inc() metrics.RootCoordDDLWriteTypeLatency.WithLabelValues("CreatePartition").Observe(float64(tr.ElapseSpan().Milliseconds())) - metrics.RootCoordNumOfPartitions.WithLabelValues(in.CollectionName).Inc() + metrics.RootCoordNumOfPartitions.WithLabelValues().Inc() return succStatus(), nil } @@ -1634,7 +1625,7 @@ func (c *Core) DropPartition(ctx context.Context, in *milvuspb.DropPartitionRequ metrics.RootCoordDropPartitionCounter.WithLabelValues(metrics.SuccessLabel).Inc() metrics.RootCoordDDLWriteTypeLatency.WithLabelValues("DropPartition").Observe(float64(tr.ElapseSpan().Milliseconds())) - metrics.RootCoordNumOfPartitions.WithLabelValues(in.CollectionName).Dec() + metrics.RootCoordNumOfPartitions.WithLabelValues().Dec() return succStatus(), nil } diff --git a/internal/rootcoord/task.go b/internal/rootcoord/task.go index 6af3876adf..9037fd92a4 100644 --- a/internal/rootcoord/task.go +++ b/internal/rootcoord/task.go @@ -24,7 +24,6 @@ import ( "github.com/golang/protobuf/proto" "github.com/milvus-io/milvus/internal/common" "github.com/milvus-io/milvus/internal/log" - "github.com/milvus-io/milvus/internal/metrics" "github.com/milvus-io/milvus/internal/proto/commonpb" "github.com/milvus-io/milvus/internal/proto/etcdpb" "github.com/milvus-io/milvus/internal/proto/internalpb" @@ -971,10 +970,6 @@ func (t *CreateIndexReqTask) Execute(ctx context.Context) error { collectionID := collMeta.ID cnt := 0 - defer func() { - metrics.RootCoordNumOfIndexedSegments.WithLabelValues(strconv.FormatInt(collectionID, 10)).Add(float64(cnt)) - }() - for _, segID := range segIDs { info := etcdpb.SegmentIndexInfo{ CollectionID: collectionID,