From 5bc85c9814ae8bad1b0f0dcfb10dd14fb14e6b90 Mon Sep 17 00:00:00 2001 From: Jonas Kaninda Date: Tue, 12 Nov 2024 15:00:16 +0100 Subject: [PATCH] refactor: improve route healthcheck --- internal/healthCheck.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/healthCheck.go b/internal/healthCheck.go index f84ae80..012c518 100644 --- a/internal/healthCheck.go +++ b/internal/healthCheck.go @@ -40,8 +40,8 @@ func (health Health) Check() error { client := &http.Client{Timeout: health.TimeOut} healthResp, err := client.Do(healthReq) if err != nil { - logger.Error("Error route %s: performing HealthCheck request: %v ", health.Name, err) - return fmt.Errorf("Error route %s: performing HealthCheck request: %v ", health.Name, err) + logger.Debug("Error route %s: performing HealthCheck request: %v ", health.Name, err) + return fmt.Errorf("error performing HealthCheck request: %v ", err) } defer func(Body io.ReadCloser) { err := Body.Close() @@ -50,13 +50,13 @@ func (health Health) Check() error { }(healthResp.Body) if len(health.HealthyStatuses) > 0 { if !slices.Contains(health.HealthyStatuses, healthResp.StatusCode) { - logger.Error("Error: Route %s: health check failed with status code %d", health.Name, healthResp.StatusCode) - return fmt.Errorf("route %s health check failed with status code %d", health.Name, healthResp.StatusCode) + logger.Debug("Error: Route %s: health check failed with status code %d", health.Name, healthResp.StatusCode) + return fmt.Errorf("health check failed with status code %d", healthResp.StatusCode) } } else { if healthResp.StatusCode >= 400 { - logger.Error("Error: Route %s: health check failed with status code %d", health.Name, healthResp.StatusCode) - return fmt.Errorf("route %s: health check failed with status code %d", health.Name, healthResp.StatusCode) + logger.Debug("Error: Route %s: health check failed with status code %d", health.Name, healthResp.StatusCode) + return fmt.Errorf("health check failed with status code %d", healthResp.StatusCode) } } return nil