Skip to content

Commit

Permalink
fix: include failed requests in total count
Browse files Browse the repository at this point in the history
closes: #147
Signed-off-by: Clément Nussbaumer <[email protected]>
  • Loading branch information
clementnuss committed Jul 22, 2024
1 parent 04caaa4 commit e5e0c55
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/servicecheck/httptrace.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func withHttptrace(registry *prometheus.Registry, next http.RoundTripper, durHis
Name: "httpclient_requests_total",
Help: "A counter for requests from the kubenurse http client.",
},
[]string{"code", "method", "type"},
[]string{"code", "type"},
)

httpclientReqDuration := prometheus.NewHistogramVec(
Expand Down Expand Up @@ -144,6 +144,11 @@ func withHttptrace(registry *prometheus.Registry, next http.RoundTripper, durHis
}
} else {
eventType := "round_trip_error"
labels := map[string]string{
"code": eventType, // we reuse round_trip_error as status code to prevent introducing a new label
"type": kubenurseRequestType,
}
httpclientReqTotal.With(labels).Inc() // also increment the total counter, as InstrumentRoundTripperCounter only instruments successful requests
// errorCounter.WithLabelValues(eventType, kubenurseRequestType).Inc()
// normally, errors are already accounted for in the ClientTrace section.
// we still log the error, so in the future we can compare the log entries and see if somehow
Expand Down

0 comments on commit e5e0c55

Please sign in to comment.