Skip to content

feat(metrics): add requests_per_prefix_total counter#556

Merged
deniszh merged 1 commit into
bookingcom:masterfrom
v-pap:requests-per-prefix-counter
Jun 17, 2026
Merged

feat(metrics): add requests_per_prefix_total counter#556
deniszh merged 1 commit into
bookingcom:masterfrom
v-pap:requests-per-prefix-counter

Conversation

@v-pap

@v-pap v-pap commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

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?

emadolsky
emadolsky previously approved these changes Jun 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown

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 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 requestsPerPrefixList API 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.

Comment thread pkg/app/carbonapi/http_handlers.go Outdated
Comment thread pkg/app/carbonapi/http_handlers.go Outdated
Comment thread pkg/app/carbonapi/http_handlers.go Outdated
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.
@v-pap v-pap force-pushed the requests-per-prefix-counter branch from c0ff616 to 816eda2 Compare June 17, 2026 13:19
@deniszh deniszh merged commit c0883e6 into bookingcom:master Jun 17, 2026
3 checks passed
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.

4 participants