util/gate: add wait duration histogram metric#18403
Open
AdeshDeshmukh wants to merge 1 commit intoprometheus:mainfrom
Open
util/gate: add wait duration histogram metric#18403AdeshDeshmukh wants to merge 1 commit intoprometheus:mainfrom
AdeshDeshmukh wants to merge 1 commit intoprometheus:mainfrom
Conversation
Adds prometheus.Histogram to Gate to track how long operations wait
for a gate slot. This allows operators to identify whether the gate
is becoming a bottleneck.
Design:
- Gate accepts prometheus.Registerer for flexible metric registration
- Caller provides metric name prefix (e.g., prometheus_remote_read_handler)
- Histogram observed after successful gate acquisition
- Optional registration: if registerer is nil, no metric recorded
Implementation:
- Gate.New() now accepts (length, registerer, metricPrefix) parameters
- Metric name: "{metricPrefix}_gate_wait_duration_seconds"
- Time measured from Start() call to gate slot acquisition
- Follows prometheus pattern used in util/notifications
Testing:
- Tests verify metric observation for normal operation
- Tests verify nil registerer (optional registration) works correctly
- Tests verify cancelled contexts don't record metrics
Fixes prometheus#11365
Signed-off-by: AdeshDeshmukh <[email protected]>
Member
|
PR #18355 also claims to fix the same issue. Is there some particular reason why we should prefer this one? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
Adds prometheus.Histogram to Gate to track how long operations wait for a gate slot. This allows operators to identify whether the gate is becoming a bottleneck.
Design
Implementation
Testing
Which issue(s) does the PR fix:
Fixes #11365
Release notes for end users
[ENHANCEMENT] util/gate: Add
gate_wait_duration_secondshistogram metric to track how long requests wait for gate availability. Callers control metric naming via the Registerer pattern, enabling bothprometheus_remote_read_handler_gate_wait_duration_secondsand component-specific variants.