Skip to content

Commit

Permalink
apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
jackgopack4 committed Nov 13, 2024
1 parent 7a3f57b commit 7aca683
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions service/telemetry/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,21 +205,19 @@ func getMetricsFromPrometheus(t *testing.T, endpoint string) map[string]*io_prom
client := &http.Client{
Timeout: 10 * time.Second,
}
var (
req *http.Request
err error
rr *http.Response
)
req, err = http.NewRequest(http.MethodGet, endpoint, nil)

req, err := http.NewRequest(http.MethodGet, endpoint, nil)
require.NoError(t, err)

var rr *http.Response
maxRetries := 5
for i := 0; i < maxRetries; i++ {
rr, err = client.Do(req)
if err == nil && rr.StatusCode == http.StatusOK {
break
}

// skip sleep on last retry
if i < maxRetries-1 {
time.Sleep(2 * time.Second) // Wait before retrying
}
Expand Down

0 comments on commit 7aca683

Please sign in to comment.