Skip to content

Add Prometheus Native Histogram defaults #129406

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions staging/src/k8s.io/component-base/metrics/buckets.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,34 @@ limitations under the License.
package metrics

import (
"time"

"github.com/prometheus/client_golang/prometheus"
)

// DefBuckets is a wrapper for prometheus.DefBuckets
var DefBuckets = prometheus.DefBuckets

// DefNativeHistogramBucketFactor defines a sane default for the Prometheus
// native histogram exponential bucket factor. The value of 1.1 means each
// bucket is 10% wider than the previous bucket.
//
// For more information on Prometheus Native Histograms, see the upstream
// client_golang documentation.
//
// https://pkg.go.dev/github.com/prometheus/client_golang/prometheus#HistogramOpts
var DefNativeHistogramBucketFactor = 1.1

// DefNativeHistogramMaxBucketNumber defines a sane default for the Prometheus
// native histogram limit to the number of sparse buckets. This avoids
// unbounded memory requirements for native histogram tracking.
var DefNativeHistogramMaxBucketNumber = 160

// DefNativeHistogramMinResetDuration defines a sane default for the Prometheus
// native histogram minimum reset duration. This is used to reset the histogram
// buckets in case the max bucket number value is reached.
var DefNativeHistogramMinResetDuration = time.Hour

// LinearBuckets is a wrapper for prometheus.LinearBuckets.
func LinearBuckets(start, width float64, count int) []float64 {
return prometheus.LinearBuckets(start, width, count)
Expand Down