core/validatorapi: fix dynamic path proxy metric#4553
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes unbounded Prometheus label cardinality for proxied validator API requests by normalizing dynamic URL path segments into placeholder tokens before recording the core_validatorapi_proxy_request_latency_seconds histogram.
Changes:
- Replaced raw proxied request path metric labels with a bounded label produced by
proxyPathLabel. - Added path-segment normalization to collapse hex (
0x…), numeric (123…), and/peers/{id}segments into placeholders. - Added unit tests covering expected label normalization and a bounded-cardinality assertion for distinct block roots.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| core/validatorapi/metrics.go | Introduces proxyPathLabel and uses it for proxy latency metric labels to prevent high-cardinality metrics. |
| core/validatorapi/metrics_internal_test.go | Adds tests validating path normalization behavior and ensuring distinct dynamic roots collapse to the same label. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4553 +/- ##
==========================================
+ Coverage 56.98% 57.03% +0.04%
==========================================
Files 245 245
Lines 33150 33168 +18
==========================================
+ Hits 18892 18918 +26
+ Misses 11870 11861 -9
- Partials 2388 2389 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|



Prometheus metrics were growing their cardinality uncontrollably on proxied requests that had slot/epoch/pubkey/val_idx in them.
category: bug
ticket: none