Skip to content

Commit

Permalink
Drop rest client request latecy metric
Browse files Browse the repository at this point in the history
In an effort to reduce the storage for nonessential memory-intensive
metrics, rest_client_request_latency_seconds was identified as the
metric that reports and stores the most time series
This metric has been deprecated since kube 1.14 and turned off in
kube 1.17
  • Loading branch information
suhanime authored and dgoodwin committed Jun 3, 2021
1 parent 0d84ce4 commit e847e4b
Showing 1 changed file with 1 addition and 22 deletions.
23 changes: 1 addition & 22 deletions pkg/metrics/client_go_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ limitations under the License.
package metrics

import (
"net/url"
"time"

"github.com/prometheus/client_golang/prometheus"
reflectormetrics "k8s.io/client-go/tools/cache"
clientmetrics "k8s.io/client-go/tools/metrics"
Expand All @@ -32,7 +29,6 @@ import (
// Metrics subsystem and all of the keys used by the rest client.
const (
RestClientSubsystem = "rest_client"
LatencyKey = "request_latency_seconds"
ResultKey = "requests_total"
)

Expand All @@ -51,13 +47,6 @@ const (

var (
// client metrics
requestLatency = prometheus.NewHistogramVec(prometheus.HistogramOpts{
Subsystem: RestClientSubsystem,
Name: LatencyKey,
Help: "Request latency in seconds. Broken down by verb and URL.",
Buckets: prometheus.ExponentialBuckets(0.001, 2, 10),
}, []string{"verb", "url"})

requestResult = prometheus.NewCounterVec(prometheus.CounterOpts{
Subsystem: RestClientSubsystem,
Name: ResultKey,
Expand Down Expand Up @@ -126,13 +115,11 @@ func init() {
// registerClientMetrics sets up the client latency metrics from client-go
func registerClientMetrics() {
// register the metrics with our registry
Registry.MustRegister(requestLatency)
Registry.MustRegister(requestResult)

// register the metrics with client-go
clientmetrics.Register(clientmetrics.RegisterOpts{
RequestLatency: &latencyAdapter{metric: requestLatency},
RequestResult: &resultAdapter{metric: requestResult},
RequestResult: &resultAdapter{metric: requestResult},
})
}

Expand All @@ -158,14 +145,6 @@ func registerReflectorMetrics() {
// copied (more-or-less directly) from k8s.io/kubernetes setup code
// (which isn't anywhere in an easily-importable place).

type latencyAdapter struct {
metric *prometheus.HistogramVec
}

func (l *latencyAdapter) Observe(verb string, u url.URL, latency time.Duration) {
l.metric.WithLabelValues(verb, u.String()).Observe(latency.Seconds())
}

type resultAdapter struct {
metric *prometheus.CounterVec
}
Expand Down

0 comments on commit e847e4b

Please sign in to comment.