Skip to content

Commit

Permalink
load request logging config from namespace rpc.server (instead of `…
Browse files Browse the repository at this point in the history
…application`) (#286)

We do this to avoid performance regression.

When loading request logging config, we have to use config center's
`Unmarshal` method, which will iterate ALL the keys in corresponding
namespace. With lots of config in namespace `application`, performance
decreases rapidly.

Co-authored-by: yanfaming8701 <[email protected]>
  • Loading branch information
yfaming and yanfaming8701 authored Sep 13, 2021
1 parent 23a7b73 commit ccf7094
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion util/service/server_grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ func shouldLogRequest(fullMethod string) bool {
printBodyMethod := printBodyMethod{}

// 方法配置
_ = center.Unmarshal(context.Background(), &printBodyMethod)
_ = center.UnmarshalWithNamespace(context.Background(), RPCServerConfNamespace, &printBodyMethod)
// 不打印的优先级更高
if methodInList(methodName, printBodyMethod.NoLogRequestMethodList) {
return false
Expand Down
2 changes: 1 addition & 1 deletion util/service/server_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ func shouldHttpLogRequest(path string) bool {
printBodyMethod := printBodyMethod{}

// 方法配置
_ = center.Unmarshal(context.Background(), &printBodyMethod)
_ = center.UnmarshalWithNamespace(context.Background(), RPCServerConfNamespace, &printBodyMethod)
// 不打印的优先级更高
if methodInList(path, printBodyMethod.NoLogRequestMethodList) {
return false
Expand Down
7 changes: 4 additions & 3 deletions util/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ const (
ENV_GROUP_PRE = "pre"

// RPCConfNamespace RPC Apollo Conf Namespace
RPCConfNamespace = "rpc.client"
ApplicationNamespace = "application"
RPCConfNamespace = "rpc.client"
RPCServerConfNamespace = "rpc.server"
ApplicationNamespace = "application"

serverStatusStop = 1
DefaultEtcdClientTimeout = 3 * time.Second
Expand Down Expand Up @@ -500,7 +501,7 @@ func newServBaseV2WithCmdArgs(confEtcd configEtcd, args *cmdArgs) (*ServBaseV2,

// init global config center
xlog.Infof(ctx, " %s init configcenter start", fun)
configCenter, err := xconfig.NewConfigCenter(context.TODO(), apollo.ConfigTypeApollo, args.servLoc, []string{ApplicationNamespace, RPCConfNamespace, xsql.MysqlConfNamespace, xmgo.MongoConfNamespace})
configCenter, err := xconfig.NewConfigCenter(context.TODO(), apollo.ConfigTypeApollo, args.servLoc, []string{ApplicationNamespace, RPCConfNamespace, RPCServerConfNamespace, xsql.MysqlConfNamespace, xmgo.MongoConfNamespace})
if err != nil {
return nil, err
}
Expand Down

0 comments on commit ccf7094

Please sign in to comment.