-
Notifications
You must be signed in to change notification settings - Fork 76
http_logger: collect information from failed round trips #1435
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
base: main
Are you sure you want to change the base?
Conversation
|
Currently, this does not work well for |
| // only process a response that is not nil | ||
| res = f.processResponse(originalRes) | ||
| } | ||
| defer res.Body.Close() |
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.
will this defer need a nil check?
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.
Fortunately no. This is old code that I will revert. It is no longer expected to be nil: Callers of this method now send a fake response that encapsulates the error if no response was created.
| if !skipSaving { | ||
| // save information from the request and failed response (if anything is available) | ||
| if res == nil { | ||
| res = &http.Response{ |
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.
This might have some unexpected consequences.
We are overwriting a nil res, which will later be returned. Perhaps a different variable name.
resToAdd := res
What this PR does / why we need it:
To collect information about requests that yield Error.
If available, collect information from the response as well.
If the response is nil, a fake response is constructed from the error object.
Here is an example extracted from an unexpected EOF error: