Skip to content

Commit

Permalink
fix: check error of httpClient.Do()
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMeier committed Nov 14, 2024
1 parent 8548f60 commit 2710846
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion downdetector-exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,10 @@ func initToken() {
}
// send the token refresh request
res, err := httpClient.Do(req)
if err != nil {
level.Error(lg).Log("msg", fmt.Sprintf("Couldn't get token: %s", err.Error()))
return
}
if res.StatusCode != 200 {
// return if we weren't successful - we have tokenGraceSeconds to retry
body, _ := io.ReadAll(res.Body)
Expand Down Expand Up @@ -454,6 +458,10 @@ func getMetrics(companyIDs string, searchString string) {
}
// send the metrics request
res, err := httpClient.Do(req)
if err != nil {
level.Error(lg).Log("msg", fmt.Sprintf("Couldn't get metrics: %s", err.Error()))
return
}
if res.StatusCode != 200 {
// return if we weren't successful
body, _ := io.ReadAll(res.Body)
Expand Down Expand Up @@ -494,7 +502,7 @@ func getMetrics(companyIDs string, searchString string) {
default:
companySet.NumStatus = -1
}
// get last value from Stats24 array
// get last value from Stats24 array
companySet.Stats15 = companySet.IgnoreStats24[len(companySet.IgnoreStats24)-1]

// Debugging output
Expand Down

0 comments on commit 2710846

Please sign in to comment.