-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: debug log gRPC queries #19049
feat: debug log gRPC queries #19049
Changes from 6 commits
8b3db7c
f6a0135
e82a084
8e56944
69590db
fde2d27
cf94348
50120cd
1c00bb7
20e1822
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ package baseapp | |
|
||
import ( | ||
"context" | ||
"fmt" | ||
"strconv" | ||
|
||
gogogrpc "github.com/cosmos/gogoproto/grpc" | ||
|
@@ -23,7 +24,7 @@ import ( | |
func (app *BaseApp) GRPCQueryRouter() *GRPCQueryRouter { return app.grpcQueryRouter } | ||
|
||
// RegisterGRPCServer registers gRPC services directly with the gRPC server. | ||
func (app *BaseApp) RegisterGRPCServer(server gogogrpc.Server) { | ||
func (app *BaseApp) RegisterGRPCServer(server gogogrpc.Server, logQueries bool) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I would instead directly supply |
||
// Define an interceptor for all gRPC queries: this interceptor will create | ||
// a new sdk.Context, and pass it into the query handler. | ||
interceptor := func(grpcCtx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) { | ||
|
@@ -67,6 +68,10 @@ func (app *BaseApp) RegisterGRPCServer(server gogogrpc.Server) { | |
app.logger.Error("failed to set gRPC header", "err", err) | ||
} | ||
|
||
if logQueries { | ||
app.logger.Debug("gRPC query received of type: " + fmt.Sprintf("%#v", req)) | ||
} | ||
|
||
return handler(grpcCtx, req) | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -182,6 +182,11 @@ max-recv-msg-size = "{{ .GRPC.MaxRecvMsgSize }}" | |
# The default value is math.MaxInt32. | ||
max-send-msg-size = "{{ .GRPC.MaxSendMsgSize }}" | ||
|
||
# LogQueries if enabled will print an info log containing the query request | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add the following here to keep confix up to date: https://github.com/cosmos/cosmos-sdk/blob/main/tools/confix/data/v0.51-app.toml ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Didn't know this existed! Added here 8e56944 |
||
# that was submitted to this node on every submission. | ||
# This is useful strictly for debugging purposes and should be disabled otherwise. | ||
log-queries = {{ .GRPC.LogQueries }} | ||
|
||
############################################################################### | ||
### gRPC Web Configuration ### | ||
############################################################################### | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add an API breaking changelog?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added here e82a084