From 6c4c0ef6b5a884ae19ebf872e1158e97a62299c8 Mon Sep 17 00:00:00 2001 From: dragondriver Date: Wed, 24 Nov 2021 15:43:15 +0800 Subject: [PATCH] Add more deploy metrics (#12248) Signed-off-by: dragondriver --- cmd/main.go | 24 +++++- internal/datacoord/metrics_info.go | 12 +-- internal/datanode/metrics_info.go | 9 +-- internal/indexcoord/metrics_info.go | 8 +- internal/indexnode/metrics_info.go | 9 +-- internal/proxy/impl.go | 13 ++++ internal/proxy/metrics_info.go | 8 +- internal/querycoord/metrics_info.go | 7 +- internal/querynode/metrics_info.go | 8 +- internal/rootcoord/metrics_info.go | 7 +- internal/util/metricsinfo/metrics_info.go | 12 +++ .../util/metricsinfo/metrics_info_test.go | 24 ++++++ internal/util/metricsinfo/utils.go | 25 +++++++ internal/util/metricsinfo/utils_test.go | 73 +++++++++++++++++++ 14 files changed, 196 insertions(+), 43 deletions(-) create mode 100644 internal/util/metricsinfo/utils.go create mode 100644 internal/util/metricsinfo/utils_test.go diff --git a/cmd/main.go b/cmd/main.go index 65cc43ac24..fad02169b9 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -72,9 +72,29 @@ func printBanner() { func injectVariablesToEnv() { // inject in need - err := os.Setenv(metricsinfo.GitCommitEnvKey, GitCommit) + var err error + + err = os.Setenv(metricsinfo.GitCommitEnvKey, GitCommit) if err != nil { - log.Warn("failed to inject git commit to environment variable", + log.Warn(fmt.Sprintf("failed to inject %s to environment variable", metricsinfo.GitCommitEnvKey), + zap.Error(err)) + } + + err = os.Setenv(metricsinfo.GitBuildTagsEnvKey, BuildTags) + if err != nil { + log.Warn(fmt.Sprintf("failed to inject %s to environment variable", metricsinfo.GitBuildTagsEnvKey), + zap.Error(err)) + } + + err = os.Setenv(metricsinfo.MilvusBuildTimeEnvKey, BuildTime) + if err != nil { + log.Warn(fmt.Sprintf("failed to inject %s to environment variable", metricsinfo.MilvusBuildTimeEnvKey), + zap.Error(err)) + } + + err = os.Setenv(metricsinfo.MilvusUsedGoVersion, GoVersion) + if err != nil { + log.Warn(fmt.Sprintf("failed to inject %s to environment variable", metricsinfo.MilvusUsedGoVersion), zap.Error(err)) } } diff --git a/internal/datacoord/metrics_info.go b/internal/datacoord/metrics_info.go index 4516948684..130cb7fb94 100644 --- a/internal/datacoord/metrics_info.go +++ b/internal/datacoord/metrics_info.go @@ -19,7 +19,6 @@ package datacoord import ( "context" "errors" - "os" "github.com/milvus-io/milvus/internal/util/uniquegenerator" @@ -90,7 +89,7 @@ func (s *Server) getSystemInfoMetrics( // getDataCoordMetrics composes datacoord infos func (s *Server) getDataCoordMetrics() metricsinfo.DataCoordInfos { - return metricsinfo.DataCoordInfos{ + ret := metricsinfo.DataCoordInfos{ BaseComponentInfos: metricsinfo.BaseComponentInfos{ Name: metricsinfo.ConstructComponentName(typeutil.DataCoordRole, Params.NodeID), HardwareInfos: metricsinfo.HardwareMetrics{ @@ -102,10 +101,7 @@ func (s *Server) getDataCoordMetrics() metricsinfo.DataCoordInfos { Disk: metricsinfo.GetDiskCount(), DiskUsage: metricsinfo.GetDiskUsage(), }, - SystemInfo: metricsinfo.DeployMetrics{ - SystemVersion: os.Getenv(metricsinfo.GitCommitEnvKey), - DeployMode: os.Getenv(metricsinfo.DeployModeEnvKey), - }, + SystemInfo: metricsinfo.DeployMetrics{}, CreatedTime: Params.CreatedTime.String(), UpdatedTime: Params.UpdatedTime.String(), Type: typeutil.DataCoordRole, @@ -115,6 +111,10 @@ func (s *Server) getDataCoordMetrics() metricsinfo.DataCoordInfos { SegmentMaxSize: Params.SegmentMaxSize, }, } + + metricsinfo.FillDeployMetricsWithEnv(&ret.BaseComponentInfos.SystemInfo) + + return ret } // getDataNodeMetrics composes data node infos diff --git a/internal/datanode/metrics_info.go b/internal/datanode/metrics_info.go index b3136caa05..87ccc5caf0 100644 --- a/internal/datanode/metrics_info.go +++ b/internal/datanode/metrics_info.go @@ -18,7 +18,6 @@ package datanode import ( "context" - "os" "github.com/milvus-io/milvus/internal/proto/commonpb" "github.com/milvus-io/milvus/internal/proto/milvuspb" @@ -40,10 +39,7 @@ func (node *DataNode) getSystemInfoMetrics(ctx context.Context, req *milvuspb.Ge Disk: metricsinfo.GetDiskCount(), DiskUsage: metricsinfo.GetDiskUsage(), }, - SystemInfo: metricsinfo.DeployMetrics{ - SystemVersion: os.Getenv(metricsinfo.GitCommitEnvKey), - DeployMode: os.Getenv(metricsinfo.DeployModeEnvKey), - }, + SystemInfo: metricsinfo.DeployMetrics{}, CreatedTime: Params.CreatedTime.String(), UpdatedTime: Params.UpdatedTime.String(), Type: typeutil.DataNodeRole, @@ -53,6 +49,9 @@ func (node *DataNode) getSystemInfoMetrics(ctx context.Context, req *milvuspb.Ge FlushInsertBufferSize: Params.FlushInsertBufferSize, }, } + + metricsinfo.FillDeployMetricsWithEnv(&nodeInfos.SystemInfo) + resp, err := metricsinfo.MarshalComponentInfos(nodeInfos) if err != nil { return &milvuspb.GetMetricsResponse{ diff --git a/internal/indexcoord/metrics_info.go b/internal/indexcoord/metrics_info.go index 45634054a8..5b5d9ab864 100644 --- a/internal/indexcoord/metrics_info.go +++ b/internal/indexcoord/metrics_info.go @@ -18,7 +18,6 @@ package indexcoord import ( "context" - "os" "github.com/milvus-io/milvus/internal/util/uniquegenerator" @@ -53,10 +52,7 @@ func getSystemInfoMetrics( Disk: metricsinfo.GetDiskCount(), DiskUsage: metricsinfo.GetDiskUsage(), }, - SystemInfo: metricsinfo.DeployMetrics{ - SystemVersion: os.Getenv(metricsinfo.GitCommitEnvKey), - DeployMode: os.Getenv(metricsinfo.DeployModeEnvKey), - }, + SystemInfo: metricsinfo.DeployMetrics{}, CreatedTime: Params.CreatedTime.String(), UpdatedTime: Params.UpdatedTime.String(), Type: typeutil.IndexCoordRole, @@ -69,6 +65,8 @@ func getSystemInfoMetrics( ConnectedNodes: make([]metricsinfo.IndexNodeInfos, 0), } + metricsinfo.FillDeployMetricsWithEnv(&clusterTopology.Self.SystemInfo) + nodesMetrics := coord.nodeManager.getMetrics(ctx, req) for _, nodeMetrics := range nodesMetrics { if nodeMetrics.err != nil { diff --git a/internal/indexnode/metrics_info.go b/internal/indexnode/metrics_info.go index 46dfa08289..e65dd7cc04 100644 --- a/internal/indexnode/metrics_info.go +++ b/internal/indexnode/metrics_info.go @@ -18,7 +18,6 @@ package indexnode import ( "context" - "os" "github.com/milvus-io/milvus/internal/proto/commonpb" "github.com/milvus-io/milvus/internal/util/metricsinfo" @@ -46,10 +45,7 @@ func getSystemInfoMetrics( Disk: metricsinfo.GetDiskCount(), DiskUsage: metricsinfo.GetDiskUsage(), }, - SystemInfo: metricsinfo.DeployMetrics{ - SystemVersion: os.Getenv(metricsinfo.GitCommitEnvKey), - DeployMode: os.Getenv(metricsinfo.DeployModeEnvKey), - }, + SystemInfo: metricsinfo.DeployMetrics{}, CreatedTime: Params.CreatedTime.String(), UpdatedTime: Params.UpdatedTime.String(), Type: typeutil.IndexNodeRole, @@ -61,6 +57,9 @@ func getSystemInfoMetrics( SimdType: Params.SimdType, }, } + + metricsinfo.FillDeployMetricsWithEnv(&nodeInfos.SystemInfo) + resp, err := metricsinfo.MarshalComponentInfos(nodeInfos) if err != nil { return &milvuspb.GetMetricsResponse{ diff --git a/internal/proxy/impl.go b/internal/proxy/impl.go index 0fccd7d020..a40d7df36a 100644 --- a/internal/proxy/impl.go +++ b/internal/proxy/impl.go @@ -2422,6 +2422,19 @@ func (node *Proxy) GetMetrics(ctx context.Context, req *milvuspb.GetMetricsReque log.Debug("Proxy.GetMetrics", zap.String("metric_type", metricType)) + msgID := UniqueID(0) + msgID, err = node.idAllocator.AllocOne() + if err != nil { + log.Warn("Proxy.GetMetrics failed to allocate id", + zap.Error(err)) + } + req.Base = &commonpb.MsgBase{ + MsgType: commonpb.MsgType_SystemInfo, + MsgID: msgID, + Timestamp: 0, + SourceID: Params.ProxyID, + } + if metricType == metricsinfo.SystemInfoMetrics { ret, err := node.metricsCacheManager.GetSystemInfoMetrics() if err == nil && ret != nil { diff --git a/internal/proxy/metrics_info.go b/internal/proxy/metrics_info.go index deca1f57ba..b120a9ddd2 100644 --- a/internal/proxy/metrics_info.go +++ b/internal/proxy/metrics_info.go @@ -18,7 +18,6 @@ package proxy import ( "context" - "os" "github.com/milvus-io/milvus/internal/proto/commonpb" @@ -48,6 +47,7 @@ func getSystemInfoMetrics( proxyRoleName := metricsinfo.ConstructComponentName(typeutil.ProxyRole, Params.ProxyID) identifierMap[proxyRoleName] = int(node.session.ServerID) + proxyTopologyNode := metricsinfo.SystemTopologyNode{ Identifier: int(node.session.ServerID), Connected: make([]metricsinfo.ConnectionEdge, 0), @@ -65,10 +65,7 @@ func getSystemInfoMetrics( Disk: metricsinfo.GetDiskCount(), DiskUsage: metricsinfo.GetDiskUsage(), }, - SystemInfo: metricsinfo.DeployMetrics{ - SystemVersion: os.Getenv(metricsinfo.GitCommitEnvKey), - DeployMode: os.Getenv(metricsinfo.DeployModeEnvKey), - }, + SystemInfo: metricsinfo.DeployMetrics{}, CreatedTime: Params.CreatedTime.String(), UpdatedTime: Params.UpdatedTime.String(), Type: typeutil.ProxyRole, @@ -80,6 +77,7 @@ func getSystemInfoMetrics( }, }, } + metricsinfo.FillDeployMetricsWithEnv(&(proxyTopologyNode.Infos.(*metricsinfo.ProxyInfos).SystemInfo)) queryCoordResp, queryCoordErr := node.queryCoord.GetMetrics(ctx, request) queryCoordRoleName := "" diff --git a/internal/querycoord/metrics_info.go b/internal/querycoord/metrics_info.go index 7910e05f2d..5b6bc71f97 100644 --- a/internal/querycoord/metrics_info.go +++ b/internal/querycoord/metrics_info.go @@ -18,7 +18,6 @@ package querycoord import ( "context" - "os" "github.com/milvus-io/milvus/internal/util/uniquegenerator" @@ -53,10 +52,7 @@ func getSystemInfoMetrics( Disk: metricsinfo.GetDiskCount(), DiskUsage: metricsinfo.GetDiskUsage(), }, - SystemInfo: metricsinfo.DeployMetrics{ - SystemVersion: os.Getenv(metricsinfo.GitCommitEnvKey), - DeployMode: os.Getenv(metricsinfo.DeployModeEnvKey), - }, + SystemInfo: metricsinfo.DeployMetrics{}, CreatedTime: Params.CreatedTime.String(), UpdatedTime: Params.UpdatedTime.String(), Type: typeutil.QueryCoordRole, @@ -69,6 +65,7 @@ func getSystemInfoMetrics( }, ConnectedNodes: make([]metricsinfo.QueryNodeInfos, 0), } + metricsinfo.FillDeployMetricsWithEnv(&clusterTopology.Self.SystemInfo) nodesMetrics := qc.cluster.getMetrics(ctx, req) for _, nodeMetrics := range nodesMetrics { diff --git a/internal/querynode/metrics_info.go b/internal/querynode/metrics_info.go index 967cc22ef1..82d47faf74 100644 --- a/internal/querynode/metrics_info.go +++ b/internal/querynode/metrics_info.go @@ -13,7 +13,6 @@ package querynode import ( "context" - "os" "github.com/milvus-io/milvus/internal/proto/commonpb" "github.com/milvus-io/milvus/internal/proto/milvuspb" @@ -42,10 +41,7 @@ func getSystemInfoMetrics(ctx context.Context, req *milvuspb.GetMetricsRequest, Disk: metricsinfo.GetDiskCount(), DiskUsage: metricsinfo.GetDiskUsage(), }, - SystemInfo: metricsinfo.DeployMetrics{ - SystemVersion: os.Getenv(metricsinfo.GitCommitEnvKey), - DeployMode: os.Getenv(metricsinfo.DeployModeEnvKey), - }, + SystemInfo: metricsinfo.DeployMetrics{}, CreatedTime: Params.CreatedTime.String(), UpdatedTime: Params.UpdatedTime.String(), Type: typeutil.QueryNodeRole, @@ -62,6 +58,8 @@ func getSystemInfoMetrics(ctx context.Context, req *milvuspb.GetMetricsRequest, SimdType: Params.SimdType, }, } + metricsinfo.FillDeployMetricsWithEnv(&nodeInfos.SystemInfo) + resp, err := metricsinfo.MarshalComponentInfos(nodeInfos) if err != nil { return &milvuspb.GetMetricsResponse{ diff --git a/internal/rootcoord/metrics_info.go b/internal/rootcoord/metrics_info.go index 4b38193219..4ce9028756 100644 --- a/internal/rootcoord/metrics_info.go +++ b/internal/rootcoord/metrics_info.go @@ -13,7 +13,6 @@ package rootcoord import ( "context" - "os" "go.uber.org/zap" @@ -39,10 +38,7 @@ func (c *Core) getSystemInfoMetrics(ctx context.Context, req *milvuspb.GetMetric Disk: metricsinfo.GetDiskCount(), DiskUsage: metricsinfo.GetDiskUsage(), }, - SystemInfo: metricsinfo.DeployMetrics{ - SystemVersion: os.Getenv(metricsinfo.GitCommitEnvKey), - DeployMode: os.Getenv(metricsinfo.DeployModeEnvKey), - }, + SystemInfo: metricsinfo.DeployMetrics{}, CreatedTime: Params.CreatedTime.String(), UpdatedTime: Params.UpdatedTime.String(), Type: typeutil.RootCoordRole, @@ -58,6 +54,7 @@ func (c *Core) getSystemInfoMetrics(ctx context.Context, req *milvuspb.GetMetric ConnectedComponents: []metricsinfo.ConnectionInfo{}, }, } + metricsinfo.FillDeployMetricsWithEnv(&rootCoordTopology.Self.SystemInfo) resp, err := metricsinfo.MarshalTopology(rootCoordTopology) if err != nil { diff --git a/internal/util/metricsinfo/metrics_info.go b/internal/util/metricsinfo/metrics_info.go index 42c5be3773..2ef031ed00 100644 --- a/internal/util/metricsinfo/metrics_info.go +++ b/internal/util/metricsinfo/metrics_info.go @@ -57,12 +57,24 @@ const ( // StandaloneDeployMode represents the stand-alone deployment mode StandaloneDeployMode = "STANDALONE" + + // GitBuildTagsEnvKey build tag + GitBuildTagsEnvKey = "MILVUS_GIT_BUILD_TAGS" + + // MilvusBuildTimeEnvKey build time + MilvusBuildTimeEnvKey = "MILVUS_BUILD_TIME" + + // MilvusUsedGoVersion used go version + MilvusUsedGoVersion = "MILVUS_USED_GO_VERSION" ) // DeployMetrics records the deploy information of nodes. type DeployMetrics struct { SystemVersion string `json:"system_version"` DeployMode string `json:"deploy_mode"` + BuildVersion string `json:"build_version"` + BuildTime string `json:"build_time"` + UsedGoVersion string `json:"used_go_version"` } // BaseComponentInfos contains basic information that all components should have. diff --git a/internal/util/metricsinfo/metrics_info_test.go b/internal/util/metricsinfo/metrics_info_test.go index 46c5ebca3b..1616888c80 100644 --- a/internal/util/metricsinfo/metrics_info_test.go +++ b/internal/util/metricsinfo/metrics_info_test.go @@ -40,6 +40,9 @@ func TestBaseComponentInfos_Codec(t *testing.T) { SystemInfo: DeployMetrics{ SystemVersion: "8b1ae98fa97ce1c7ba853e8b9ff1c7ce24458dc1", DeployMode: ClusterDeployMode, + BuildVersion: "2.0.0-rc8", + BuildTime: "2021-11-24, 11:37:25", + UsedGoVersion: "go version go1.15.2 linux/amd64", }, CreatedTime: time.Now().String(), UpdatedTime: time.Now().String(), @@ -74,6 +77,9 @@ func TestQueryNodeInfos_Codec(t *testing.T) { SystemInfo: DeployMetrics{ SystemVersion: "8b1ae98fa97ce1c7ba853e8b9ff1c7ce24458dc1", DeployMode: ClusterDeployMode, + BuildVersion: "2.0.0-rc8", + BuildTime: "2021-11-24, 11:37:25", + UsedGoVersion: "go version go1.15.2 linux/amd64", }, CreatedTime: time.Now().String(), UpdatedTime: time.Now().String(), @@ -119,6 +125,9 @@ func TestQueryCoordInfos_Codec(t *testing.T) { SystemInfo: DeployMetrics{ SystemVersion: "8b1ae98fa97ce1c7ba853e8b9ff1c7ce24458dc1", DeployMode: ClusterDeployMode, + BuildVersion: "2.0.0-rc8", + BuildTime: "2021-11-24, 11:37:25", + UsedGoVersion: "go version go1.15.2 linux/amd64", }, CreatedTime: time.Now().String(), UpdatedTime: time.Now().String(), @@ -158,6 +167,9 @@ func TestIndexNodeInfos_Codec(t *testing.T) { SystemInfo: DeployMetrics{ SystemVersion: "8b1ae98fa97ce1c7ba853e8b9ff1c7ce24458dc1", DeployMode: ClusterDeployMode, + BuildVersion: "2.0.0-rc8", + BuildTime: "2021-11-24, 11:37:25", + UsedGoVersion: "go version go1.15.2 linux/amd64", }, CreatedTime: time.Now().String(), UpdatedTime: time.Now().String(), @@ -198,6 +210,9 @@ func TestIndexCoordInfos_Codec(t *testing.T) { SystemInfo: DeployMetrics{ SystemVersion: "8b1ae98fa97ce1c7ba853e8b9ff1c7ce24458dc1", DeployMode: ClusterDeployMode, + BuildVersion: "2.0.0-rc8", + BuildTime: "2021-11-24, 11:37:25", + UsedGoVersion: "go version go1.15.2 linux/amd64", }, CreatedTime: time.Now().String(), UpdatedTime: time.Now().String(), @@ -236,6 +251,9 @@ func TestDataNodeInfos_Codec(t *testing.T) { SystemInfo: DeployMetrics{ SystemVersion: "8b1ae98fa97ce1c7ba853e8b9ff1c7ce24458dc1", DeployMode: ClusterDeployMode, + BuildVersion: "2.0.0-rc8", + BuildTime: "2021-11-24, 11:37:25", + UsedGoVersion: "go version go1.15.2 linux/amd64", }, CreatedTime: time.Now().String(), UpdatedTime: time.Now().String(), @@ -274,6 +292,9 @@ func TestDataCoordInfos_Codec(t *testing.T) { SystemInfo: DeployMetrics{ SystemVersion: "8b1ae98fa97ce1c7ba853e8b9ff1c7ce24458dc1", DeployMode: ClusterDeployMode, + BuildVersion: "2.0.0-rc8", + BuildTime: "2021-11-24, 11:37:25", + UsedGoVersion: "go version go1.15.2 linux/amd64", }, CreatedTime: time.Now().String(), UpdatedTime: time.Now().String(), @@ -312,6 +333,9 @@ func TestRootCoordInfos_Codec(t *testing.T) { SystemInfo: DeployMetrics{ SystemVersion: "8b1ae98fa97ce1c7ba853e8b9ff1c7ce24458dc1", DeployMode: ClusterDeployMode, + BuildVersion: "2.0.0-rc8", + BuildTime: "2021-11-24, 11:37:25", + UsedGoVersion: "go version go1.15.2 linux/amd64", }, CreatedTime: time.Now().String(), UpdatedTime: time.Now().String(), diff --git a/internal/util/metricsinfo/utils.go b/internal/util/metricsinfo/utils.go new file mode 100644 index 0000000000..cd038c9b28 --- /dev/null +++ b/internal/util/metricsinfo/utils.go @@ -0,0 +1,25 @@ +// Copyright (C) 2019-2020 Zilliz. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software distributed under the License +// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +// or implied. See the License for the specific language governing permissions and limitations under the License. + +package metricsinfo + +import ( + "os" +) + +// FillDeployMetricsWithEnv fill deploy metrics with env. +func FillDeployMetricsWithEnv(m *DeployMetrics) { + m.SystemVersion = os.Getenv(GitCommitEnvKey) + m.DeployMode = os.Getenv(DeployModeEnvKey) + m.BuildVersion = os.Getenv(GitBuildTagsEnvKey) + m.UsedGoVersion = os.Getenv(MilvusUsedGoVersion) + m.BuildTime = os.Getenv(MilvusBuildTimeEnvKey) +} diff --git a/internal/util/metricsinfo/utils_test.go b/internal/util/metricsinfo/utils_test.go new file mode 100644 index 0000000000..d93cb3067a --- /dev/null +++ b/internal/util/metricsinfo/utils_test.go @@ -0,0 +1,73 @@ +// Copyright (C) 2019-2020 Zilliz. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software distributed under the License +// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +// or implied. See the License for the specific language governing permissions and limitations under the License. + +package metricsinfo + +import ( + "os" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestFillDeployMetricsWithEnv(t *testing.T) { + var err error + + var m DeployMetrics + + commit := "commit" + originalCommit := os.Getenv(GitCommitEnvKey) + err = os.Setenv(GitCommitEnvKey, commit) + assert.NoError(t, err) + + deploy := "deploy" + originalDeploy := os.Getenv(DeployModeEnvKey) + err = os.Setenv(DeployModeEnvKey, deploy) + assert.NoError(t, err) + + version := "version" + originalVersion := os.Getenv(GitBuildTagsEnvKey) + err = os.Setenv(GitBuildTagsEnvKey, version) + assert.NoError(t, err) + + goVersion := "go" + originalGoVersion := os.Getenv(MilvusUsedGoVersion) + err = os.Setenv(MilvusUsedGoVersion, goVersion) + assert.NoError(t, err) + + buildTime := "build" + originalBuildTime := os.Getenv(MilvusBuildTimeEnvKey) + err = os.Setenv(MilvusBuildTimeEnvKey, buildTime) + assert.NoError(t, err) + + FillDeployMetricsWithEnv(&m) + assert.NotNil(t, m) + assert.Equal(t, commit, m.SystemVersion) + assert.Equal(t, deploy, m.DeployMode) + assert.Equal(t, version, m.BuildVersion) + assert.Equal(t, goVersion, m.UsedGoVersion) + assert.Equal(t, buildTime, m.BuildTime) + + err = os.Setenv(GitCommitEnvKey, originalCommit) + assert.NoError(t, err) + + err = os.Setenv(DeployModeEnvKey, originalDeploy) + assert.NoError(t, err) + + err = os.Setenv(GitBuildTagsEnvKey, originalVersion) + assert.NoError(t, err) + + err = os.Setenv(MilvusUsedGoVersion, originalGoVersion) + assert.NoError(t, err) + + err = os.Setenv(MilvusBuildTimeEnvKey, originalBuildTime) + assert.NoError(t, err) +}