Skip to content

feat: Make Prometheus gRPC histogram buckets configurable#35

Merged
ankurs merged 1 commit intomainfrom
feat/configurable-grpc-prom
Feb 11, 2026
Merged

feat: Make Prometheus gRPC histogram buckets configurable#35
ankurs merged 1 commit intomainfrom
feat/configurable-grpc-prom

Conversation

@kevinjom
Copy link
Contributor

@kevinjom kevinjom commented Feb 11, 2026

Add support for custom histogram buckets for gRPC request latency metrics via PROMETHEUS_GRPC_HISTOGRAM_BUCKETS environment variable.

Summary by CodeRabbit

  • New Features
    • Added support for customizing Prometheus gRPC histogram buckets to provide fine-tuned observability metrics collection. Users can now specify custom bucket threshold values (comma-separated seconds) via a new environment variable. When this variable is not configured, the system automatically applies sensible default histogram buckets for standard usage scenarios and typical workloads.

Add support for custom histogram buckets for gRPC request latency
metrics via PROMETHEUS_GRPC_HISTOGRAM_BUCKETS environment variable.
@coderabbitai
Copy link

coderabbitai bot commented Feb 11, 2026

📝 Walkthrough

Walkthrough

The PR adds support for custom Prometheus gRPC histogram buckets. A new configuration field PrometheusGRPCHistogramBuckets is introduced to the Config struct, populated from an environment variable. The initialization logic is updated to apply these custom buckets when provided, or fall back to default buckets when empty.

Changes

Cohort / File(s) Summary
Configuration Enhancement
config/config.go
Added new public field PrometheusGRPCHistogramBuckets []float64 with environment variable binding and documentation for comma-separated histogram bucket values in seconds.
Histogram Initialization
core.go
Updated gRPC histogram setup to conditionally apply custom buckets from config when non-empty, otherwise use default buckets.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 A config field hops into place,
Custom buckets now keep the pace,
Prometheus metrics, tuned just right,
Histograms gleam with buckets so bright! 📊

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely summarizes the main change: making Prometheus gRPC histogram buckets configurable, which matches the core functionality added across config and core files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/configurable-grpc-prom

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_BUCKETS config 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.

Comment on lines +31 to +34
// 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:""`
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@ankurs ankurs merged commit 617e044 into main Feb 11, 2026
12 checks passed
@ankurs ankurs deleted the feat/configurable-grpc-prom branch February 11, 2026 06:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants