-
Notifications
You must be signed in to change notification settings - Fork 1
Improve resiliency on 404 responses #139
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: master
Are you sure you want to change the base?
Improve resiliency on 404 responses #139
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.
Comment @cursor review or bugbot run to trigger another review on this PR
|
bugbot run |
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.
Comment @cursor review or bugbot run to trigger another review on this PR
|
bugbot run |
| } | ||
|
|
||
| response, err = c.httpClient.Do(req) | ||
| if err != nil || (response != nil && response.StatusCode >= 500) { |
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 response != nil happen when err == nil? I think not?
| for attempt := 0; attempt < 3; attempt++ { | ||
| if attempt > 0 && bodyBytes != nil { | ||
| req.Body = io.NopCloser(bytes.NewReader(bodyBytes)) | ||
| } |
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 for loop could be extracted to a function that gets passed the inner logic so that retries and http response handling is separated
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.
You might also get more control over response.Body.Close() as you could end up in a construction where you can always defer it instead of handling the separate cases throughout the logic
| var jobs []queryJob | ||
| var configs []queryConfig | ||
| var jobsMutex sync.RWMutex |
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: the jobsMutex and jobs fields can be extracted to a type that ensures concurrency safe operations.
To make humio_exporter more resilient, I've made some changes, so it doesn't crash on all 404 or 5xx responses.
Part of ESA-1044