From 8e5ac70c0a22ce885e22d939042a2fc2d7938416 Mon Sep 17 00:00:00 2001 From: Brad Ison Date: Fri, 25 Oct 2024 12:19:53 -0500 Subject: [PATCH] Enable native histograms in server latency metrics --- pkg/cmd/server/defaults.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/cmd/server/defaults.go b/pkg/cmd/server/defaults.go index c7463cba04..b829607927 100644 --- a/pkg/cmd/server/defaults.go +++ b/pkg/cmd/server/defaults.go @@ -489,7 +489,13 @@ func createServerMetrics(disableHistogram bool) (grpc.UnaryServerInterceptor, gr var opts []grpcprom.ServerMetricsOption if !disableHistogram { opts = append(opts, grpcprom.WithServerHandlingTimeHistogram( - grpcprom.WithHistogramBuckets([]float64{.001, .003, .006, .010, .018, .024, .032, .042, .056, .075, .100, .178, .316, .562, 1, 5}), + grpcprom.WithHistogramOpts(&prometheus.HistogramOpts{ + NativeHistogramBucketFactor: 1.1, // At most 10% increase from bucket to bucket. + NativeHistogramMaxBucketNumber: 100, + Buckets: []float64{ + .001, .003, .006, .010, .018, .024, .032, .042, .056, .075, .100, .178, .316, .562, 1, 5, + }, + }), )) } srvMetrics := grpcprom.NewServerMetrics(opts...)