-
Notifications
You must be signed in to change notification settings - Fork 683
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
Request Logging #311
Request Logging #311
Conversation
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.
Hm, I still don't get the need for separate logger.
We have already one reporter. One Request is needed? the reporter
is also request.
The only missing log line would be on start which we can do based on decider, no? 🤔
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.
So far so good. I've left a couple of suggestions.
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.
Hm, not sure about it either, will take a look closer how we could implement it and let's talk on our 1:2 cc @kakkoyun
There is easy way how to do what we want btw (: |
After having a 1:2 call with @bwplotka and @kakkoyun, we decided to modify the objectives of this PR -
This is a bit different from the original implementation because in the earlier PR, we were logging all the messages of the stream, which is quite verbose and irrelevant. |
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.
Nice, looking awesome, just minor nits!
Hey Everyone, this PR is ready to be merged. |
564b8f0
to
fddea8d
Compare
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.
Hm, I somehow don't see the latest revision of this, let's discuss
Tests failing due to - #319 |
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.
It's really LGTM, just small nits on the actual message logged (: and maybe decider.
This PR shows that we might be missing details in the initial design about the "interface" of this change.
The interface is really:
- how user will configure
- what users will see on different configuration.
Can we add some design section for it to make it clear? (: It would avoid some confusion.
IMO:
- Human readable consistent message, and having all variables as fields (e.g type, method as well!)
finished call
andstarted call
is really enough if we would havecomponent:server
field or something, right?- What about single decider:
type LogDecision struct {
LogStarted, LogFinished bool
}
type Decider func (....) Decision
The alternative is:
type Decider int
const (
NoLog Decider = iota
LogStarted
LogFinished
)
WDYT? (:
Changes made uptil now -
Changes that need to be made -
|
I would like to extend the
Interface of new Decider -
WDYT? |
16bdb25
to
36928b5
Compare
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.
nit
@yashrsharma44 Ok, the interface is apparently different than I had assumed so you can ignore my comments or even better we can update the interface since this is a v2 branch. |
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.
Some notes after 1:1
Looks like we want decider to NOT have error and do adaptive logging base on error, using errCode to Log Level, 💪 Looks like we are going into simpler functions, which means I think I would vote for |
b6037e9
to
a4186b1
Compare
Once we fixate on the Decider implementation, I can start with the examples 🤓 |
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.
Nice, Looking good! Small things only.
Add changes from bartek's review
…rom the server side Signed-off-by: Yash Sharma <yashrsharma44@gmail.com>
Signed-off-by: Yash Sharma <yashrsharma44@gmail.com>
…rt and end of request and response start messages Signed-off-by: Yash Sharma <yashrsharma44@gmail.com>
Signed-off-by: Yash Sharma <yashrsharma44@gmail.com>
Signed-off-by: Yash Sharma <yashrsharma44@gmail.com>
* Unary Server testing * Stream server testing * Unary Error testing Signed-off-by: Yash Sharma <yashrsharma44@gmail.com> nitpickings Signed-off-by: Yash Sharma <yashrsharma44@gmail.com> more nitpickings Signed-off-by: Yash Sharma <yashrsharma44@gmail.com>
* return early for multiple cases * intialize the level early Signed-off-by: Yash Sharma <yashrsharma44@gmail.com>
* Now enabling logging logs out all the details of the request/response * Breaks the initial logging api Signed-off-by: Yash Sharma <yashrsharma44@gmail.com>
… encoding Signed-off-by: Yash Sharma <yashrsharma44@gmail.com>
* Human Readable Messages - All the log entries are changed to use space instead of `_`. * Using key-value pairs for storing the kind, type and component. * Changed to start call and finished call. Signed-off-by: Yash Sharma <yashrsharma44@gmail.com>
Signed-off-by: Yash Sharma <yashrsharma44@gmail.com>
Signed-off-by: Yash Sharma <yashrsharma44@gmail.com>
* Abstracted out repititive fields into a single method * Added test fields, instead of creating a whole suite * Changed field values to adhere the common convention Signed-off-by: Yash Sharma <yashrsharma44@gmail.com>
…suite rather than creating a new suite Signed-off-by: Yash Sharma <yashrsharma44@gmail.com>
Signed-off-by: Yash Sharma <yashrsharma44@gmail.com>
* Currently 3 types of logging configured * NoLogCall - No logging * LogFinishCall - For logging the end of the call * LogAllCall - For logging the start and end of the call Signed-off-by: Yash Sharma <yashrsharma44@gmail.com>
Signed-off-by: Yash Sharma <yashrsharma44@gmail.com>
Signed-off-by: Yash Sharma <yashrsharma44@gmail.com>
Signed-off-by: Yash Sharma <yashrsharma44@gmail.com> More comments removal Signed-off-by: Yash Sharma <yashrsharma44@gmail.com>
a5cd904
to
88ee96c
Compare
Signed-off-by: Yash Sharma <yashrsharma44@gmail.com>
99445b3
to
fbc8146
Compare
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.
Tiny nit only, we can fix that later (:
LGTM, Thanks! 👍
code := c.opts.codeFunc(err) | ||
logger = logger.With("grpc.code", code.String()) | ||
if err != nil { | ||
logger = logger.With("grpc.error", fmt.Sprintf("%v", err)) |
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.
logger = logger.With("grpc.error", fmt.Sprintf("%v", err)) | |
logger = logger.With("grpc.error", err.Error()) |
@@ -47,12 +60,12 @@ func DefaultErrorToCode(err error) codes.Code { | |||
} | |||
|
|||
// Decider function defines rules for suppressing any interceptor logs | |||
type Decider func(fullMethodName string, err error) bool | |||
type Decider func(fullMethodName string) Decision |
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.
Would have been nice not to have skipped the error parameter here. The logging can also be configured using the error as well,(since status code can be derived from the response error).
This PR achieves to add in a Request/Response logger in
grpc_middlewares
v2
branch.Fixes #310
Current TODO -
Initial setup for the RequestReporterConfigure the request logger in the old logger itselfref: https://github.com/grpc-ecosystem/go-grpc-middleware/pull/311/files#diff-0c98eb4ff4e54e07ef0a999e5d5bd678R137
If any suggestions are there, feel free to add in more 😅
Signed-off-by: Yash Sharma yashrsharma44@gmail.com