feat(metrics): add requests_per_prefix_total counter#556
Merged
Conversation
emadolsky
previously approved these changes
Jun 17, 2026
There was a problem hiding this comment.
Pull request overview
Adds an opt-in Prometheus counter to measure how often /render requests directly reference configured metric-name prefixes, enabling per-prefix request volume tracking when requestsPerPrefixList is set in API config.
Changes:
- Introduces
requestsPerPrefixListAPI configuration for validated per-prefix counting. - Adds
requests_per_prefix_total{prefix=...}Prometheus counter and registers it. - Implements per-request prefix matching in
renderHandler, plus unit tests for prefix matching and prefix-list validation.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/cfg/api.go | Adds RequestsPerPrefixList YAML config field and documentation. |
| pkg/app/carbonapi/metrics.go | Defines and registers the requests_per_prefix_total CounterVec. |
| pkg/app/carbonapi/http_handlers.go | Implements prefix matching in /render and increments the counter. |
| pkg/app/carbonapi/http_handlers_test.go | Adds tests for metricRefsPrefix and initRequestPrefixes. |
| pkg/app/carbonapi/app.go | Stores validated prefixes on App and adds initRequestPrefixes validation helper. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Adds a configurable per-prefix counter on /render. Each request
increments requests_per_prefix_total{prefix=...} once per configured
prefix that is directly referenced by one of its target metric
patterns (metric == prefix, or metric starts with '<prefix>.').
Configured via the new requestsPerPrefixList yaml key on the api
side. Empty/glob entries are dropped at startup. Field is nil by
default — feature stays silent until configured.
c0ff616 to
816eda2
Compare
deniszh
approved these changes
Jun 17, 2026
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.
Adds a configurable per-prefix counter on /render. Each request increments requests_per_prefix_total{prefix=...} once per configured prefix that is directly referenced by one of its target metric patterns (metric == prefix, or metric starts with '.').
Configured via the new requestsPerPrefixList yaml key on the api side. Empty/glob entries are dropped at startup. Field is nil by default — feature stays silent until configured.
What issue is this change attempting to solve?
How does this change solve the problem? Why is this the best approach?
How can we be sure this works as expected?