Metrics: Add ability to disable classic histogram for HTTP metric (#88315)

metrics: Add ability to disable classic histogram for HTTP metric

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>
This commit is contained in:
Dave Henderson
2024-06-18 15:37:44 -04:00
committed by GitHub
parent 9b7f9ae22e
commit 3bbc821131
7 changed files with 236 additions and 224 deletions

View File

@@ -51,12 +51,19 @@ func RequestMetrics(features featuremgmt.FeatureToggles, cfg *setting.Cfg, promR
if features.IsEnabledGlobally(featuremgmt.FlagEnableNativeHTTPHistogram) {
// the recommended default value from the prom_client
// https://github.com/prometheus/client_golang/blob/main/prometheus/histogram.go#L411
// Giving this variable an value means the client will expose the histograms as an
// native histogram instead of normal a normal histogram.
// Giving this variable a value means the client will expose a native
// histogram.
histogramOptions.NativeHistogramBucketFactor = 1.1
// The default value in OTel. It probably good enough for us as well.
histogramOptions.NativeHistogramMaxBucketNumber = 160
histogramOptions.NativeHistogramMinResetDuration = time.Hour
if features.IsEnabledGlobally(featuremgmt.FlagDisableClassicHTTPHistogram) {
// setting Buckets to nil with native options set means the classic
// histogram will no longer be exposed - this can be a good way to
// reduce cardinality in the exposed metrics
histogramOptions.Buckets = nil
}
}
httpRequestDurationHistogram := prometheus.NewHistogramVec(