feat: Make Prometheus gRPC histogram buckets configurable#35
Conversation
Add support for custom histogram buckets for gRPC request latency metrics via PROMETHEUS_GRPC_HISTOGRAM_BUCKETS environment variable.
📝 WalkthroughWalkthroughThe PR adds support for custom Prometheus gRPC histogram buckets. A new configuration field Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Adds an opt-in configuration for Prometheus gRPC handling-time histogram bucket boundaries, allowing operators to tune latency distributions via an environment variable while preserving the library defaults when unset.
Changes:
- Added
PROMETHEUS_GRPC_HISTOGRAM_BUCKETSconfig field ([]float64) to supply custom bucket thresholds (seconds). - Updated Prometheus gRPC histogram initialization to apply custom buckets when configured, otherwise fall back to go-grpc-prometheus defaults.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| core.go | Conditionally enables gRPC handling-time histograms with custom bucket boundaries when configured. |
| config/config.go | Introduces a new config field and documentation comment for supplying histogram buckets via env var. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // PrometheusGRPCHistogramBuckets specifies custom histogram buckets for gRPC request latency metrics | ||
| // Format: comma-separated float values in seconds (e.g., "0.005,0.01,0.025,0.05,0.1,0.25,0.5,1,2.5,5,10") | ||
| // If empty, uses the default buckets from go-grpc-prometheus | ||
| PrometheusGRPCHistogramBuckets []float64 `envconfig:"PROMETHEUS_GRPC_HISTOGRAM_BUCKETS" default:""` |
There was a problem hiding this comment.
config/README.md is gomarkdoc-generated from config/config.go and currently doesn’t include the newly added PrometheusGRPCHistogramBuckets field. Please regenerate/update the generated docs so the public configuration documentation matches the code.
Add support for custom histogram buckets for gRPC request latency metrics via PROMETHEUS_GRPC_HISTOGRAM_BUCKETS environment variable.
Summary by CodeRabbit