mirror of
https://github.com/kubernetes-sigs/prometheus-adapter.git
synced 2026-04-06 01:38:10 +00:00
add http status code to APIResponse
This commit is contained in:
parent
00c093074c
commit
b01d7ac59d
3 changed files with 26 additions and 23 deletions
|
|
@ -92,18 +92,8 @@ func (c *instrumentedGenericClient) Do(ctx context.Context, verb, endpoint strin
|
|||
var resp client.APIResponse
|
||||
defer func() {
|
||||
endTime := time.Now()
|
||||
if err != nil {
|
||||
if apiErr, wasAPIErr := err.(*client.Error); wasAPIErr {
|
||||
// measure API errors
|
||||
apiRequestsTotal.With(prometheus.Labels{"code": string(apiErr.Type), "path": endpoint, "server": c.serverName}).Inc()
|
||||
} else {
|
||||
// increment a generic error code counter
|
||||
apiRequestsTotal.With(prometheus.Labels{"code": "generic", "path": endpoint, "server": c.serverName}).Inc()
|
||||
}
|
||||
return
|
||||
} else {
|
||||
apiRequestsTotal.With(prometheus.Labels{"code": string(resp.Status), "path": endpoint, "server": c.serverName}).Inc()
|
||||
}
|
||||
|
||||
apiRequestsTotal.With(prometheus.Labels{"code": string(resp.HTTPStatusCode), "path": endpoint, "server": c.serverName}).Inc()
|
||||
queryLatency.With(prometheus.Labels{"path": endpoint, "server": c.serverName}).Observe(endTime.Sub(startTime).Seconds())
|
||||
}()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue