-
Notifications
You must be signed in to change notification settings - Fork 166
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
proxy access log #2301
proxy access log #2301
Conversation
Could we log request bodies in Debug mode? |
8699835
to
1dc7aac
Compare
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
how much of it? 100 bytes, kb or mb? I think if you want to log all the request bodies adding a real proxy would make more sense? or what use case do you have in mind? |
Mainly debugging json and webdav bodies, headers. Yeah I didn't have file-uploads in mind so this might be not viable. Maybe based on content-type. But maybe this is to complicated or should be an additional param. |
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
Kudos, SonarCloud Quality Gate passed! |
@refs we might be able to log the routing policy by making the selector decision in a middleware and putting it in a context. Then the proxy handler can read it from the context. but since that is a little bigger refactoring I'd defer that to another PR. The routing policy is logged in debug mode. We at least now hale a proper access log. |
wrap := middleware.NewWrapResponseWriter(w, r.ProtoMajor) | ||
next.ServeHTTP(wrap, r) | ||
|
||
logger.Info(). |
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.
Shouldn't the log be called before next.ServeHTTP
?
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.
no, the log needs to know the duration so it has to happen after next.ServeHTTP(wrap, r)
next.ServeHTTP(wrap, r) | ||
|
||
logger.Info(). | ||
Str("proto", r.Proto). |
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.
Str("proto", r.Proto). | |
Str("protocol", r.Proto). |
GET THIS IN, THIS IS GOOD NEWS! |
We now use a dedicated middleware to log all requests, regardless of routing selector outcome. The log now includes the remote address and the selected routing policy.