Add module name to logger in proxy (#13580)

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

Co-authored-by: sunby <bingyi.sun@zilliz.com>
pull/13662/head
Bingyi Sun 2021-12-17 19:07:39 +08:00 committed by GitHub
parent ecd3dc5830
commit 37705dfbbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 6 deletions

View File

@ -351,7 +351,8 @@ func (mr *MilvusRoles) Run(localMsg bool, alias string) {
var pn *components.Proxy
if mr.EnableProxy {
pn = mr.runProxy(ctx, localMsg, alias)
pctx := logutil.WithModule(ctx, "Proxy")
pn = mr.runProxy(pctx, localMsg, alias)
if pn != nil {
defer pn.Stop()
}

View File

@ -24,6 +24,7 @@ import (
"strconv"
"github.com/milvus-io/milvus/internal/common"
"github.com/milvus-io/milvus/internal/logutil"
"github.com/milvus-io/milvus/internal/util/funcutil"
@ -46,6 +47,8 @@ import (
"github.com/milvus-io/milvus/internal/util/typeutil"
)
const moduleName = "Proxy"
// UpdateStateCode updates the state code of Proxy.
func (node *Proxy) UpdateStateCode(code internalpb.StateCode) {
node.stateCode.Store(code)
@ -94,7 +97,8 @@ func (node *Proxy) GetStatisticsChannel(ctx context.Context) (*milvuspb.StringRe
// InvalidateCollectionMetaCache invalidate the meta cache of specific collection.
func (node *Proxy) InvalidateCollectionMetaCache(ctx context.Context, request *proxypb.InvalidateCollMetaCacheRequest) (*commonpb.Status, error) {
log.Debug("InvalidateCollectionMetaCache",
ctx = logutil.WithModule(ctx, moduleName)
logutil.Logger(ctx).Debug("received request to invalidate collection meta cache",
zap.String("role", typeutil.ProxyRole),
zap.String("db", request.DbName),
zap.String("collection", request.CollectionName))
@ -103,7 +107,7 @@ func (node *Proxy) InvalidateCollectionMetaCache(ctx context.Context, request *p
if globalMetaCache != nil {
globalMetaCache.RemoveCollection(ctx, collectionName) // no need to return error, though collection may be not cached
}
log.Debug("InvalidateCollectionMetaCache Done",
logutil.Logger(ctx).Debug("complete to invalidate collection meta cache",
zap.String("role", typeutil.ProxyRole),
zap.String("db", request.DbName),
zap.String("collection", request.CollectionName))
@ -116,7 +120,8 @@ func (node *Proxy) InvalidateCollectionMetaCache(ctx context.Context, request *p
// ReleaseDQLMessageStream release the query message stream of specific collection.
func (node *Proxy) ReleaseDQLMessageStream(ctx context.Context, request *proxypb.ReleaseDQLMessageStreamRequest) (*commonpb.Status, error) {
log.Debug("ReleaseDQLMessageStream",
ctx = logutil.WithModule(ctx, moduleName)
logutil.Logger(ctx).Debug("received request to release DQL message strem",
zap.Any("role", typeutil.ProxyRole),
zap.Any("db", request.DbID),
zap.Any("collection", request.CollectionID))
@ -127,7 +132,7 @@ func (node *Proxy) ReleaseDQLMessageStream(ctx context.Context, request *proxypb
_ = node.chMgr.removeDQLStream(request.CollectionID)
log.Debug("ReleaseDQLMessageStream Done",
logutil.Logger(ctx).Debug("complete to release DQL message stream",
zap.Any("role", typeutil.ProxyRole),
zap.Any("db", request.DbID),
zap.Any("collection", request.CollectionID))

View File

@ -25,6 +25,7 @@ import (
"syscall"
"time"
"github.com/milvus-io/milvus/internal/logutil"
"github.com/milvus-io/milvus/internal/util/metricsinfo"
"github.com/milvus-io/milvus/internal/metrics"
@ -103,7 +104,7 @@ func NewProxy(ctx context.Context, factory msgstream.Factory) (*Proxy, error) {
msFactory: factory,
}
node.UpdateStateCode(internalpb.StateCode_Abnormal)
log.Debug("Proxy", zap.Any("State", node.stateCode.Load()))
logutil.Logger(ctx).Debug("create a new Proxy instance", zap.Any("state", node.stateCode.Load()))
return node, nil
}