-
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 5 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.Info("gRPC query received of type: " + fmt.Sprintf("%#v", req)) | ||
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. why not put this as debug and use log filtering for the info you need? another config variable seems overkill here 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. The thought here is, this will only be enabled in the event we are actively debugging something, and have an integrator to send me their info logs is much easier than asking to send massive debug logs and/or filter it themselves. Happy to change it in this PR for the sdk, will probably keep as info for the fork for now though. 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. i think this is what filter logging was created for or one of the reasons. It would be much cleaner to ask an integrator to turn on debugging and paste "....." in the filter logs. This way they only get the logs you want. Currently this approach you will need to ask for a snapshot or they will need to search for the log along side all the other infos. The filter would be to see blocks are being created and this debug log. So you as the debugger would make your life easier. This is encroaching on devops territory which there are tools for, we dont want to make the sdk more complicated to run and debug. 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. Np, will change sdk side 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. 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. sorry i meant no config changes, just a debug statement 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. For a node under heavy load like ours (250 rps), this might make the debug logs impossible to grok. I know one can filter but it seems helpful for the logs to be somewhat manageable, and there are rare edge cases where this info is needed. I think a config makes the most sense. 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. this introduces two ways to do the same thing. feels like this will be confusing to users as if they try to filter for this log it wont show up since its blocked on another config value. We can add it but I feel its over kill for something already suported 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. I can remove it, I just wanted to explain why I added it as a config in the first place. I am actually not familiar with the debug filtering at all so that's why this wasn't clear to me. Happy to remove it |
||
} | ||
|
||
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