Skip to content

Commit c384db8

Browse files
rabenhorstHC Zhu
authored andcommitted
Replace summary in extprom metrics with histogram (thanos-io#6327)
* Replaced summary in extprom metrics with histogram Signed-off-by: Sebastian Rabenhorst <[email protected]> * Added changelog Signed-off-by: Sebastian Rabenhorst <[email protected]> * Removed unused parameters from NewInstrumentationMiddleware Signed-off-by: Sebastian Rabenhorst <[email protected]> * Reverted NewInstrumentationMiddleware Signed-off-by: Sebastian Rabenhorst <[email protected]> --------- Signed-off-by: Sebastian Rabenhorst <[email protected]>
1 parent f60717a commit c384db8

File tree

2 files changed

+29
-16
lines changed

2 files changed

+29
-16
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re
4141
- [#6303](https://github.com/thanos-io/thanos/pull/6303) Store: added and start using streamed snappy encoding for postings list instead of block based one. This leads to constant memory usage during decompression. This approximately halves memory usage when decompressing a postings list in index cache.
4242
- [#6071](https://github.com/thanos-io/thanos/pull/6071) Query Frontend: *breaking :warning:* Add experimental native histogram support for which we updated and aligned with the [Prometheus common](https://github.com/prometheus/common) model, which is used for caching so a cache reset required.
4343
- [#6163](https://github.com/thanos-io/thanos/pull/6163) Receiver: changed max backoff from 30s to 5s for forwarding requests. Can be configured with `--receive-forward-max-backoff`.
44+
- [#6327](https://github.com/thanos-io/thanos/pull/6327) *: *breaking :warning:* Use histograms instead of summaries for instrumented handlers.
4445

4546
### Removed
4647

pkg/extprom/http/metrics.go

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,40 @@ import (
1010

1111
type defaultMetrics struct {
1212
requestDuration *prometheus.HistogramVec
13-
requestSize *prometheus.SummaryVec
13+
requestSize *prometheus.HistogramVec
1414
requestsTotal *prometheus.CounterVec
15-
responseSize *prometheus.SummaryVec
15+
responseSize *prometheus.HistogramVec
1616
inflightHTTPRequests *prometheus.GaugeVec
1717
}
1818

19-
func newDefaultMetrics(reg prometheus.Registerer, buckets []float64, extraLabels []string) *defaultMetrics {
20-
if buckets == nil {
21-
buckets = []float64{0.001, 0.01, 0.1, 0.3, 0.6, 1, 3, 6, 9, 20, 30, 60, 90, 120, 240, 360, 720}
19+
func newDefaultMetrics(reg prometheus.Registerer, durationBuckets []float64, extraLabels []string) *defaultMetrics {
20+
if durationBuckets == nil {
21+
durationBuckets = []float64{0.001, 0.01, 0.1, 0.3, 0.6, 1, 3, 6, 9, 20, 30, 60, 90, 120, 240, 360, 720}
2222
}
2323

24+
bytesBuckets := prometheus.ExponentialBuckets(64, 2, 10)
25+
bucketFactor := 1.1
26+
maxBuckets := uint32(100)
27+
2428
return &defaultMetrics{
2529
requestDuration: promauto.With(reg).NewHistogramVec(
2630
prometheus.HistogramOpts{
27-
Name: "http_request_duration_seconds",
28-
Help: "Tracks the latencies for HTTP requests.",
29-
Buckets: buckets,
31+
Name: "http_request_duration_seconds",
32+
Help: "Tracks the latencies for HTTP requests.",
33+
Buckets: durationBuckets,
34+
NativeHistogramBucketFactor: bucketFactor,
35+
NativeHistogramMaxBucketNumber: maxBuckets,
3036
},
3137
append([]string{"code", "handler", "method"}, extraLabels...),
3238
),
3339

34-
requestSize: promauto.With(reg).NewSummaryVec(
35-
prometheus.SummaryOpts{
36-
Name: "http_request_size_bytes",
37-
Help: "Tracks the size of HTTP requests.",
40+
requestSize: promauto.With(reg).NewHistogramVec(
41+
prometheus.HistogramOpts{
42+
Name: "http_request_size_bytes",
43+
Help: "Tracks the size of HTTP requests.",
44+
Buckets: bytesBuckets,
45+
NativeHistogramBucketFactor: bucketFactor,
46+
NativeHistogramMaxBucketNumber: maxBuckets,
3847
},
3948
append([]string{"code", "handler", "method"}, extraLabels...),
4049
),
@@ -47,10 +56,13 @@ func newDefaultMetrics(reg prometheus.Registerer, buckets []float64, extraLabels
4756
append([]string{"code", "handler", "method"}, extraLabels...),
4857
),
4958

50-
responseSize: promauto.With(reg).NewSummaryVec(
51-
prometheus.SummaryOpts{
52-
Name: "http_response_size_bytes",
53-
Help: "Tracks the size of HTTP responses.",
59+
responseSize: promauto.With(reg).NewHistogramVec(
60+
prometheus.HistogramOpts{
61+
Name: "http_response_size_bytes",
62+
Help: "Tracks the size of HTTP responses.",
63+
Buckets: bytesBuckets,
64+
NativeHistogramBucketFactor: bucketFactor,
65+
NativeHistogramMaxBucketNumber: maxBuckets,
5466
},
5567
append([]string{"code", "handler", "method"}, extraLabels...),
5668
),

0 commit comments

Comments
 (0)