Add log with context in DataCoord (#14431)

Signed-off-by: sunby <bingyi.sun@zilliz.com>

Co-authored-by: sunby <bingyi.sun@zilliz.com>
This commit is contained in:
Bingyi Sun 2021-12-28 19:42:19 +08:00 committed by GitHub
parent b4a04a36ab
commit 02e568603b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -210,8 +210,10 @@ func (mr *MilvusRoles) runDataCoord(ctx context.Context, localMsg bool) *compone
f := setLoggerFunc() f := setLoggerFunc()
datacoord.Params.BaseParams.SetLogConfig(f) datacoord.Params.BaseParams.SetLogConfig(f)
factory := newMsgFactory(localMsg) factory := newMsgFactory(localMsg)
dctx := logutil.WithModule(ctx, "DataCoord")
var err error var err error
ds, err = components.NewDataCoord(ctx, factory) ds, err = components.NewDataCoord(dctx, factory)
if err != nil { if err != nil {
panic(err) panic(err)
} }

View File

@ -214,9 +214,9 @@ func (s *Server) QuitSignal() <-chan struct{} {
func (s *Server) Register() error { func (s *Server) Register() error {
s.session.Register() s.session.Register()
go s.session.LivenessCheck(s.serverLoopCtx, func() { go s.session.LivenessCheck(s.serverLoopCtx, func() {
log.Error("DataCoord disconnected from etcd and exited", zap.Int64("ServerID", s.session.ServerID)) logutil.Logger(s.ctx).Error("disconnected from etcd and exited", zap.Int64("serverID", s.session.ServerID))
if err := s.Stop(); err != nil { if err := s.Stop(); err != nil {
log.Fatal("failed to stop server", zap.Error(err)) logutil.Logger(s.ctx).Fatal("failed to stop server", zap.Error(err))
} }
// manually send signal to starter goroutine // manually send signal to starter goroutine
syscall.Kill(syscall.Getpid(), syscall.SIGINT) syscall.Kill(syscall.Getpid(), syscall.SIGINT)
@ -291,7 +291,7 @@ func (s *Server) Start() error {
Params.DataCoordCfg.CreatedTime = time.Now() Params.DataCoordCfg.CreatedTime = time.Now()
Params.DataCoordCfg.UpdatedTime = time.Now() Params.DataCoordCfg.UpdatedTime = time.Now()
atomic.StoreInt64(&s.isServing, ServerStateHealthy) atomic.StoreInt64(&s.isServing, ServerStateHealthy)
log.Debug("DataCoord startup success") logutil.Logger(s.ctx).Debug("startup success")
return nil return nil
} }