Skip to content

Commit

Permalink
turn down prober log levels
Browse files Browse the repository at this point in the history
Signed-off-by: Bob Callaway <[email protected]>
  • Loading branch information
bobcallaway committed Dec 16, 2024
1 parent 3c81724 commit 857f768
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cmd/prober/prober.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ func init() {
retryableClient.RequestLogHook = func(_ retryablehttp.Logger, r *http.Request, attempt int) {
ctx := context.WithValue(r.Context(), attemptCtxKey("attempt_number"), attempt)
*r = *r.WithContext(ctx)
Logger.Infof("attempt #%d for %v %v", attempt, r.Method, r.URL)
Logger.Debugf("attempt #%d for %v %v", attempt, r.Method, r.URL)
}
retryableClient.ResponseLogHook = func(_ retryablehttp.Logger, r *http.Response) {
attempt := r.Request.Context().Value(attemptCtxKey("attempt_number"))
Logger.With(zap.Int("bytes", int(r.ContentLength))).Infof("attempt #%d result: %d", attempt, r.StatusCode)
Logger.With(zap.Int("bytes", int(r.ContentLength))).Debugf("attempt #%d result: %d", attempt, r.StatusCode)
}

var rekorFlagRequests []ReadProberCheck
Expand Down
12 changes: 10 additions & 2 deletions cmd/prober/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ func exportDataToPrometheus(resp *http.Response, host, endpoint, method string,
endpointLatenciesSummary.With(labels).Observe(float64(latency))
endpointLatenciesHistogram.With(labels).Observe(float64(latency))

Logger.With(zap.Int("status", statusCode), zap.Int("bytes", int(resp.ContentLength)), zap.Duration("latency", time.Duration(latency)*time.Millisecond)).Infof("[DEBUG] %v %v", method, host+endpoint)
if statusCode >= 400 {
Logger.With(zap.Int("status", statusCode), zap.Int("bytes", int(resp.ContentLength)), zap.Duration("latency", time.Duration(latency)*time.Millisecond)).Warnf("[DEBUG] %v %v", method, host+endpoint)
} else {
Logger.With(zap.Int("status", statusCode), zap.Int("bytes", int(resp.ContentLength)), zap.Duration("latency", time.Duration(latency)*time.Millisecond)).Debugf("[DEBUG] %v %v", method, host+endpoint)
}
}

func exportGrpcDataToPrometheus(statusCode codes.Code, host string, endpoint string, method string, latency int64) {
Expand All @@ -82,7 +86,11 @@ func exportGrpcDataToPrometheus(statusCode codes.Code, host string, endpoint str
}
endpointLatenciesSummary.With(labels).Observe(float64(latency))
endpointLatenciesHistogram.With(labels).Observe(float64(latency))
Logger.With(zap.Int32("status", int32(statusCode)), zap.Duration("latency", time.Duration(latency)*time.Millisecond)).Infof("[DEBUG] %v %v %v", method, endpoint, host)
if statusCode != codes.OK {
Logger.With(zap.Int32("status", int32(statusCode)), zap.Duration("latency", time.Duration(latency)*time.Millisecond)).Warnf("[DEBUG] %v %v %v", method, endpoint, host)
} else {
Logger.With(zap.Int32("status", int32(statusCode)), zap.Duration("latency", time.Duration(latency)*time.Millisecond)).Debugf("[DEBUG] %v %v %v", method, endpoint, host)
}
}

// NewVersionCollector returns a collector that exports metrics about current version
Expand Down

0 comments on commit 857f768

Please sign in to comment.