Skip to content

Commit 46e815a

Browse files
committed
fix
1 parent 2a6c4c4 commit 46e815a

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

agent/apphealth.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package agent
33
import (
44
"context"
55
"net/http"
6-
"net/url"
76
"sync"
87
"time"
98

@@ -65,19 +64,16 @@ func reportAppHealth(ctx context.Context, logger slog.Logger, fetchApps FetchWor
6564
Timeout: time.Duration(app.HealthcheckInterval),
6665
}
6766
err := func() error {
68-
u, err := url.Parse(app.HealthcheckURL)
67+
req, err := http.NewRequestWithContext(ctx, http.MethodGet, app.HealthcheckURL, nil)
6968
if err != nil {
7069
return err
7170
}
72-
res, err := client.Do(&http.Request{
73-
Method: http.MethodGet,
74-
URL: u,
75-
})
71+
res, err := client.Do(req)
7672
if err != nil {
7773
return err
7874
}
7975
res.Body.Close()
80-
if res.StatusCode > 499 {
76+
if res.StatusCode >= http.StatusInternalServerError {
8177
return xerrors.Errorf("error status code: %d", res.StatusCode)
8278
}
8379

@@ -110,7 +106,7 @@ func reportAppHealth(ctx context.Context, logger slog.Logger, fetchApps FetchWor
110106
case <-reportTicker.C:
111107
mu.RLock()
112108
changed := healthChanged(lastHealth, health)
113-
mu.Unlock()
109+
mu.RUnlock()
114110
if changed {
115111
lastHealth = health
116112
err := reportHealth(ctx, health)

0 commit comments

Comments
 (0)