Skip to content

Commit

Permalink
Replace summary in extprom metrics with histogram (#6327)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
rabenhorst authored May 3, 2023
1 parent a1ec4d5 commit 9855151
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re
- [#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.
- [#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.
- [#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`.
- [#6327](https://github.com/thanos-io/thanos/pull/6327) *: *breaking :warning:* Use histograms instead of summaries for instrumented handlers.

### Removed

Expand Down
44 changes: 28 additions & 16 deletions pkg/extprom/http/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,40 @@ import (

type defaultMetrics struct {
requestDuration *prometheus.HistogramVec
requestSize *prometheus.SummaryVec
requestSize *prometheus.HistogramVec
requestsTotal *prometheus.CounterVec
responseSize *prometheus.SummaryVec
responseSize *prometheus.HistogramVec
inflightHTTPRequests *prometheus.GaugeVec
}

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

bytesBuckets := prometheus.ExponentialBuckets(64, 2, 10)
bucketFactor := 1.1
maxBuckets := uint32(100)

return &defaultMetrics{
requestDuration: promauto.With(reg).NewHistogramVec(
prometheus.HistogramOpts{
Name: "http_request_duration_seconds",
Help: "Tracks the latencies for HTTP requests.",
Buckets: buckets,
Name: "http_request_duration_seconds",
Help: "Tracks the latencies for HTTP requests.",
Buckets: durationBuckets,
NativeHistogramBucketFactor: bucketFactor,
NativeHistogramMaxBucketNumber: maxBuckets,
},
append([]string{"code", "handler", "method"}, extraLabels...),
),

requestSize: promauto.With(reg).NewSummaryVec(
prometheus.SummaryOpts{
Name: "http_request_size_bytes",
Help: "Tracks the size of HTTP requests.",
requestSize: promauto.With(reg).NewHistogramVec(
prometheus.HistogramOpts{
Name: "http_request_size_bytes",
Help: "Tracks the size of HTTP requests.",
Buckets: bytesBuckets,
NativeHistogramBucketFactor: bucketFactor,
NativeHistogramMaxBucketNumber: maxBuckets,
},
append([]string{"code", "handler", "method"}, extraLabels...),
),
Expand All @@ -47,10 +56,13 @@ func newDefaultMetrics(reg prometheus.Registerer, buckets []float64, extraLabels
append([]string{"code", "handler", "method"}, extraLabels...),
),

responseSize: promauto.With(reg).NewSummaryVec(
prometheus.SummaryOpts{
Name: "http_response_size_bytes",
Help: "Tracks the size of HTTP responses.",
responseSize: promauto.With(reg).NewHistogramVec(
prometheus.HistogramOpts{
Name: "http_response_size_bytes",
Help: "Tracks the size of HTTP responses.",
Buckets: bytesBuckets,
NativeHistogramBucketFactor: bucketFactor,
NativeHistogramMaxBucketNumber: maxBuckets,
},
append([]string{"code", "handler", "method"}, extraLabels...),
),
Expand Down

0 comments on commit 9855151

Please sign in to comment.