Skip to content

Commit 267ad6f

Browse files
committed
optimized performance: dropped size metrics, dropped buckets
1 parent b9e8b85 commit 267ad6f

File tree

1 file changed

+2
-34
lines changed

1 file changed

+2
-34
lines changed

pkg/metrics/client_go_adapter.go

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,7 @@ var (
3232
prometheus.HistogramOpts{
3333
Name: "rest_client_request_duration_seconds",
3434
Help: "Request latency in seconds. Broken down by verb, and host.",
35-
Buckets: []float64{0.005, 0.025, 0.1, 0.25, 0.5, 1.0, 2.0, 4.0, 8.0, 15.0, 30.0, 60.0},
36-
},
37-
[]string{"verb", "host"},
38-
)
39-
40-
requestSize = prometheus.NewHistogramVec(
41-
prometheus.HistogramOpts{
42-
Name: "rest_client_request_size_bytes",
43-
Help: "Request size in bytes. Broken down by verb and host.",
44-
// 64 bytes to 16MB
45-
Buckets: []float64{64, 256, 512, 1024, 4096, 16384, 65536, 262144, 1048576, 4194304, 16777216},
46-
},
47-
[]string{"verb", "host"},
48-
)
49-
50-
responseSize = prometheus.NewHistogramVec(
51-
prometheus.HistogramOpts{
52-
Name: "rest_client_response_size_bytes",
53-
Help: "Response size in bytes. Broken down by verb and host.",
54-
// 64 bytes to 16MB
55-
Buckets: []float64{64, 256, 512, 1024, 4096, 16384, 65536, 262144, 1048576, 4194304, 16777216},
35+
Buckets: []float64{}, // Intentionally not using buckets for better performance.
5636
},
5737
[]string{"verb", "host"},
5838
)
@@ -61,7 +41,7 @@ var (
6141
prometheus.HistogramOpts{
6242
Name: "rest_client_rate_limiter_duration_seconds",
6343
Help: "Client side rate limiter latency in seconds. Broken down by verb, and host.",
64-
Buckets: []float64{0.005, 0.025, 0.1, 0.25, 0.5, 1.0, 2.0, 4.0, 8.0, 15.0, 30.0, 60.0},
44+
Buckets: []float64{}, // Intentionally not using buckets for better performance.
6545
},
6646
[]string{"verb", "host"},
6747
)
@@ -91,17 +71,13 @@ func init() {
9171
func registerClientMetrics() {
9272
// register the metrics with our registry
9373
Registry.MustRegister(requestLatency)
94-
Registry.MustRegister(requestSize)
95-
Registry.MustRegister(responseSize)
9674
Registry.MustRegister(rateLimiterLatency)
9775
Registry.MustRegister(requestResult)
9876
Registry.MustRegister(requestRetry)
9977

10078
// register the metrics with client-go
10179
clientmetrics.Register(clientmetrics.RegisterOpts{
10280
RequestLatency: &LatencyAdapter{metric: requestLatency},
103-
RequestSize: &sizeAdapter{metric: requestSize},
104-
ResponseSize: &sizeAdapter{metric: responseSize},
10581
RateLimiterLatency: &LatencyAdapter{metric: rateLimiterLatency},
10682
RequestResult: &resultAdapter{metric: requestResult},
10783
RequestRetry: &retryAdapter{requestRetry},
@@ -126,14 +102,6 @@ func (l *LatencyAdapter) Observe(_ context.Context, verb string, u url.URL, late
126102
l.metric.WithLabelValues(verb, u.String()).Observe(latency.Seconds())
127103
}
128104

129-
type sizeAdapter struct {
130-
metric *prometheus.HistogramVec
131-
}
132-
133-
func (s *sizeAdapter) Observe(ctx context.Context, verb string, host string, size float64) {
134-
s.metric.WithLabelValues(verb, host).Observe(size)
135-
}
136-
137105
type resultAdapter struct {
138106
metric *prometheus.CounterVec
139107
}

0 commit comments

Comments
 (0)