mirror of
https://github.com/kubernetes-sigs/prometheus-adapter.git
synced 2026-04-06 01:38:10 +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"},
|
[]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) {
|
func MetricsHandler() (http.HandlerFunc, error) {
|
||||||
registry := metrics.NewKubeRegistry()
|
registry := metrics.NewKubeRegistry()
|
||||||
|
err := registry.Register(queryLatency)
|
||||||
errRegisterQueryLatency := registry.Register(queryLatency)
|
if err != nil {
|
||||||
if errRegisterQueryLatency != nil {
|
return nil, err
|
||||||
return nil, errRegisterQueryLatency
|
|
||||||
}
|
}
|
||||||
|
|
||||||
errRegisterAPIErrorCount := registry.Register(apiErrorCount)
|
|
||||||
if errRegisterAPIErrorCount != nil {
|
|
||||||
return nil, errRegisterAPIErrorCount
|
|
||||||
}
|
|
||||||
|
|
||||||
apimetrics.Register()
|
apimetrics.Register()
|
||||||
return func(w http.ResponseWriter, req *http.Request) {
|
return func(w http.ResponseWriter, req *http.Request) {
|
||||||
legacyregistry.Handler().ServeHTTP(w, req)
|
legacyregistry.Handler().ServeHTTP(w, req)
|
||||||
|
|
@ -92,15 +74,11 @@ func (c *instrumentedGenericClient) Do(ctx context.Context, verb, endpoint strin
|
||||||
endTime := time.Now()
|
endTime := time.Now()
|
||||||
// skip calls where we don't make the actual request
|
// skip calls where we don't make the actual request
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if apiErr, wasAPIErr := err.(*client.Error); wasAPIErr {
|
if _, wasAPIErr := err.(*client.Error); !wasAPIErr {
|
||||||
// Measure API errors
|
// TODO: measure API errors by code?
|
||||||
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
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
queryLatency.With(prometheus.Labels{"path": endpoint, "server": c.serverName}).Observe(endTime.Sub(startTime).Seconds())
|
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