Skip to content

Commit

Permalink
Added debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
patilsuraj767 committed Oct 12, 2023
1 parent 75ceeeb commit 989a62c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions internal/utils/kruize/kruize_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,16 @@ func Update_results(experiment_name string, k8s_object []map[string]interface{})

// Update metrics to kruize experiment
url := cfg.KruizeUrl + "/updateResults"

log.Debugf("\n Sending /updateResult request to kruize with payload - %s \n", string(postBody))
res, err := http.Post(url, "application/json", bytes.NewBuffer(postBody))
if err != nil {
kruizeAPIException.WithLabelValues("/updateResults").Inc()
return nil, fmt.Errorf("an Error Occured while sending metrics: %v", err)
}
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
log.Debugf("\n Respose from API /updateResult - %s \n", string(body))
if res.StatusCode != 201 {
body, _ := io.ReadAll(res.Body)
resdata := kruizePayload.UpdateResultResponse{}
if err := json.Unmarshal(body, &resdata); err != nil {
return nil, fmt.Errorf("can not unmarshal response data: %v", err)
Expand Down Expand Up @@ -153,13 +154,15 @@ func Update_recommendations(experiment_name string, interval_end_time time.Time)
q.Add("experiment_name", experiment_name)
q.Add("interval_end_time", utils.ConvertDateToISO8601(interval_end_time.String()))
req.URL.RawQuery = q.Encode()
log.Debugf("\n Sending /updateRecommendations request to kruize - %s \n", q)
res, err := client.Do(req)
if err != nil {
kruizeAPIException.WithLabelValues("/updateRecommendations").Inc()
return nil, fmt.Errorf("error Occured while calling /updateRecommendations API %v", err)
}
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
log.Debugf("\nResponse from /updateRecommendations - %s \n", string(body))
if res.StatusCode == 400 {
data := map[string]interface{}{}
if err := json.Unmarshal(body, &data); err != nil {
Expand Down

0 comments on commit 989a62c

Please sign in to comment.