-
Notifications
You must be signed in to change notification settings - Fork 452
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
Bug fix + various code/logging improvements to retry code #643
Conversation
@@ -329,7 +346,7 @@ func (s *BackendConfiguration) Do(req *http.Request, v interface{}) error { | |||
} | |||
|
|||
if s.LogLevel > 2 { | |||
s.Logger.Printf("Stripe Response: %q\n", resBody) | |||
s.Logger.Printf("Response: %s\n", string(resBody)) |
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.
Changed the %q
to a %s
with a string(...)
cast because the %q
produces lots of noisy escaping that's not really needed for anything and detrimental to legibility:
Stripe Response: \"{\\\\"id\\\": \\\"ch_*\\\",\
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.
LGTM
This one is a variety of improvements to the retry code: * Fixed one bug whereby for a failed request, we were not reading the entire response body before trying to log it, which results in an uninformative output like `&{409....`. Here we add a `ReadAll`. * I denested some code so that we have less indentation. * I changed measuring request time to measuring individual requests around `s.HTTPClient.Do` instead of measuring the entire span including all the sleeping the retry block is doing. * I added logging for the amount of time the program is about to go to sleep before a retry. You can still get the total execution time by adding the time for all requests plus the time for all sleeps. * Generally changed some logs around for consistency around format, casing, and punctuation. The impetus is that I was trying to understand the code to debug #642. This might help get some visibility into a solution, but won't solve the problem.
b85fc2c
to
3c4328a
Compare
Thanks Remi! |
Released as 38.1.0. |
This one is a variety of improvements to the retry code:
entire response body before trying to log it, which results in an
uninformative output like
&{409....
. Here we add aReadAll
.around
s.HTTPClient.Do
instead of measuring the entire spanincluding all the sleeping the retry block is doing.
sleep before a retry. You can still get the total execution time by
adding the time for all requests plus the time for all sleeps.
casing, and punctuation.
The impetus is that I was trying to understand the code to debug #642.
This might help get some visibility into a solution, but won't solve the
problem.
r? @remi-stripe
cc @stripe/api-libraries