Skip to content

Commit

Permalink
Add even more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
leszko committed Sep 4, 2024
1 parent 29a33f5 commit 54c81eb
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions metrics/monitor_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package metrics
import (
"context"
"fmt"
"github.com/golang/glog"
"net/http"
"time"

Expand All @@ -20,18 +21,22 @@ func MonitorRequest(clientMetrics ClientMetrics, client *http.Client, r *http.Re
req := r.WithContext(ctx)

start := time.Now()
glog.Infof("client.Do(req)")
res, err := client.Do(req)
glog.Infof("Done client.Do(req), err=%v", err)
duration := time.Since(start)

retries := ctx.Value(RetriesKey).(*Retries)
if retries.lastStatusCode >= 400 {
glog.Infof("retries.lastStatusCode >= 400")
clientMetrics.FailureCount.WithLabelValues(req.URL.Host, fmt.Sprint(retries.lastStatusCode)).Inc()
return res, err
}

clientMetrics.RequestDuration.WithLabelValues(req.URL.Host).Observe(duration.Seconds())
clientMetrics.RetryCount.WithLabelValues(req.URL.Host).Set(float64(retries.count))

glog.Infof("return res, err")
return res, err
}

Expand Down

0 comments on commit 54c81eb

Please sign in to comment.