Description
Prometheus is fragile against high-cardinality labels. Add a registration wrapper that requires each metric to declare a cardinality budget and refuses new label combinations that would exceed it.
Requirements and context
- Must be secure, tested, and documented
- Should be efficient and easy to review
- Relevant code:
src/metrics.ts, src/metrics/slotMetrics.ts
- Drop or relabel offenders to
__overflow__
Suggested execution
- Fork the repo and create a branch
git checkout -b feat/metric-cardinality-budgets
- Implement changes
- Wrapper API requiring
{name, labels, budget}
- LRU map of seen label tuples per metric
- Emit
metric_cardinality_overflow_total counter
- Validate security and correctness assumptions
Test and commit
- Run tests
- Cover edge cases
- Budget set to 0 falls back to no-label aggregation
- Include test output and notes
Example commit message
feat: metric label cardinality budgets
Guidelines
- Minimum 95 percent test coverage
- Clear documentation
- Timeframe: 96 hours
Description
Prometheus is fragile against high-cardinality labels. Add a registration wrapper that requires each metric to declare a cardinality budget and refuses new label combinations that would exceed it.
Requirements and context
src/metrics.ts,src/metrics/slotMetrics.ts__overflow__Suggested execution
git checkout -b feat/metric-cardinality-budgets{name, labels, budget}metric_cardinality_overflow_totalcounterTest and commit
npm testExample commit message
feat: metric label cardinality budgetsGuidelines