From 2735cab1f8467aeb7bdcdd47f50f5ab7b38ee1f5 Mon Sep 17 00:00:00 2001 From: aryanmehrotra Date: Wed, 10 Jun 2026 09:20:02 +0530 Subject: [PATCH] fix(wrap): extend generated gRPC histogram buckets to 3 minutes The generated gRPC latency histograms (app_gRPC-Server_stats, app_gRPC-Stream_stats, app_gRPC-Client_stats) capped their buckets at 10ms, so any RPC slower than 10ms fell into +Inf and the histogram carried no usable distribution above that point. Extend the bucket range up to 180000 (3 minutes), keeping the existing fine-grained low end. gRPC duration is recorded in fractional milliseconds, so the buckets stay in milliseconds and the existing descriptions remain correct. --- wrap/template.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/wrap/template.go b/wrap/template.go index 66ff672..4e08aa4 100644 --- a/wrap/template.go +++ b/wrap/template.go @@ -565,7 +565,10 @@ func registerServerWithGofr(app *gofr.App, srv any, registerFunc func(grpc.Servi // Register metrics and health server only once if !healthServerRegistered { - gRPCBuckets := []float64{0.005, 0.01, .05, .075, .1, .125, .15, .2, .3, .5, .75, 1, 2, 3, 4, 5, 7.5, 10} + gRPCBuckets := []float64{ + 0.005, 0.01, .05, .075, .1, .125, .15, .2, .3, .5, .75, 1, 2, 3, 4, 5, 7.5, 10, // 5µs-10ms + 25, 50, 100, 250, 500, 1000, 5000, 10000, 30000, 60000, 120000, 180000, // 25ms-3min + } app.Metrics().NewHistogram("app_gRPC-Server_stats", "Response time of gRPC server in milliseconds.", gRPCBuckets...) app.Metrics().NewHistogram("app_gRPC-Stream_stats", "Duration of gRPC stream in milliseconds.", gRPCBuckets...) @@ -655,7 +658,10 @@ import ( var ( metricsOnce sync.Once - gRPCBuckets = []float64{0.005, 0.01, .05, .075, .1, .125, .15, .2, .3, .5, .75, 1, 2, 3, 4, 5, 7.5, 10} + gRPCBuckets = []float64{ + 0.005, 0.01, .05, .075, .1, .125, .15, .2, .3, .5, .75, 1, 2, 3, 4, 5, 7.5, 10, // 5µs-10ms + 25, 50, 100, 250, 500, 1000, 5000, 10000, 30000, 60000, 120000, 180000, // 25ms-3min + } ) type HealthClient interface {