Expose created time and updated time to indexnode metrics (#8592)

Signed-off-by: dragondriver <jiquan.long@zilliz.com>
pull/8212/head
dragondriver 2021-09-26 17:56:08 +08:00 committed by GitHub
parent 0d41efe154
commit 68b9da219a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 2 deletions

View File

@ -167,6 +167,9 @@ func (i *IndexNode) Start() error {
i.once.Do(func() {
startErr = i.sched.Start()
Params.CreatedTime = time.Now()
Params.UpdatedTime = time.Now()
//start liveness check
go i.session.LivenessCheck(i.loopCtx, i.liveCh, func() {
i.Stop()

View File

@ -45,7 +45,8 @@ func getSystemInfoMetrics(
SystemVersion: os.Getenv(metricsinfo.GitCommitEnvKey),
DeployMode: os.Getenv(metricsinfo.DeployModeEnvKey),
},
// TODO(dragondriver): CreatedTime & UpdatedTime, easy but time-costing
CreatedTime: Params.CreatedTime.String(),
UpdatedTime: Params.UpdatedTime.String(),
Type: typeutil.IndexNodeRole,
},
SystemConfigurations: metricsinfo.IndexNodeConfiguration{

View File

@ -17,6 +17,7 @@ import (
"strconv"
"strings"
"sync"
"time"
"go.uber.org/zap"
@ -49,6 +50,9 @@ type ParamTable struct {
SimdType string
CreatedTime time.Time
UpdatedTime time.Time
Log log.Config
}

View File

@ -13,6 +13,7 @@ package indexnode
import (
"testing"
"time"
)
func TestParamTable(t *testing.T) {
@ -71,6 +72,16 @@ func TestParamTable(t *testing.T) {
})
// FIXME(dragondriver): how to cover panic case? we use `LoadWithDefault` to initialize `SimdType`
t.Run("CreatedTime", func(t *testing.T) {
Params.CreatedTime = time.Now()
t.Logf("CreatedTime: %v", Params.CreatedTime)
})
t.Run("UpdatedTime", func(t *testing.T) {
Params.UpdatedTime = time.Now()
t.Logf("UpdatedTime: %v", Params.UpdatedTime)
})
}
//TODO: Params Load should be return error when key does not exist.