mirror of
https://github.com/kubernetes-sigs/prometheus-adapter.git
synced 2026-04-05 17:27:51 +00:00
revert changes
This commit is contained in:
parent
5af792b7d6
commit
2621acaf1d
1 changed files with 7 additions and 29 deletions
|
|
@ -45,32 +45,14 @@ var (
|
|||
},
|
||||
[]string{"path", "server"},
|
||||
)
|
||||
|
||||
// define a counter for API errors for various ErrorTypes
|
||||
apiErrorCount = metrics.NewCounterVec(
|
||||
&metrics.CounterOpts{
|
||||
Namespace: "prometheus_adapter",
|
||||
Subsystem: "prometheus_client",
|
||||
Name: "api_errors_total",
|
||||
Help: "Total number of API errors",
|
||||
},
|
||||
[]string{"error_code", "path", "server"},
|
||||
)
|
||||
)
|
||||
|
||||
func MetricsHandler() (http.HandlerFunc, error) {
|
||||
registry := metrics.NewKubeRegistry()
|
||||
|
||||
errRegisterQueryLatency := registry.Register(queryLatency)
|
||||
if errRegisterQueryLatency != nil {
|
||||
return nil, errRegisterQueryLatency
|
||||
err := registry.Register(queryLatency)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
errRegisterAPIErrorCount := registry.Register(apiErrorCount)
|
||||
if errRegisterAPIErrorCount != nil {
|
||||
return nil, errRegisterAPIErrorCount
|
||||
}
|
||||
|
||||
apimetrics.Register()
|
||||
return func(w http.ResponseWriter, req *http.Request) {
|
||||
legacyregistry.Handler().ServeHTTP(w, req)
|
||||
|
|
@ -92,14 +74,10 @@ func (c *instrumentedGenericClient) Do(ctx context.Context, verb, endpoint strin
|
|||
endTime := time.Now()
|
||||
// skip calls where we don't make the actual request
|
||||
if err != nil {
|
||||
if apiErr, wasAPIErr := err.(*client.Error); wasAPIErr {
|
||||
// Measure API errors
|
||||
apiErrorCount.With(prometheus.Labels{"error_code": string(apiErr.Type), "path": endpoint, "server": c.serverName}).Inc()
|
||||
} else {
|
||||
// Increment a generic error code counter
|
||||
apiErrorCount.With(prometheus.Labels{"error_code": "generic", "path": endpoint, "server": c.serverName}).Inc()
|
||||
}
|
||||
return
|
||||
if _, wasAPIErr := err.(*client.Error); !wasAPIErr {
|
||||
// TODO: measure API errors by code?
|
||||
return
|
||||
}
|
||||
}
|
||||
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