Skip to content

Conversation

@JacobValdemar
Copy link
Member

@JacobValdemar JacobValdemar commented Dec 9, 2025

To make humio_exporter more resilient, I've made some changes, so it doesn't crash on all 404 or 5xx responses.

  • For 404s: We now detect ErrQueryNotFound and restart the query job instead of sending to done (triggering crashing)
  • For 5xx: We now retry up to 3 times before giving up, so transient server errors don't cause immediate crashes

Part of ESA-1044

@JacobValdemar JacobValdemar requested a review from a team as a code owner December 9, 2025 13:59
Copy link

@cursor cursor bot left a 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

@JacobValdemar
Copy link
Member Author

bugbot run

Copy link

@cursor cursor bot left a 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

@JacobValdemar
Copy link
Member Author

bugbot run

}

response, err = c.httpClient.Do(req)
if err != nil || (response != nil && response.StatusCode >= 500) {
Copy link
Member

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?

Comment on lines +118 to +121
for attempt := 0; attempt < 3; attempt++ {
if attempt > 0 && bodyBytes != nil {
req.Body = io.NopCloser(bytes.NewReader(bodyBytes))
}
Copy link
Member

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

Copy link
Member

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

Comment on lines 165 to +167
var jobs []queryJob
var configs []queryConfig
var jobsMutex sync.RWMutex
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants