Skip to content

core/validatorapi: fix dynamic path proxy metric#4553

Merged
KaloyanTanev merged 2 commits into
mainfrom
kalo/fix-proxy-metrics
Jun 8, 2026
Merged

core/validatorapi: fix dynamic path proxy metric#4553
KaloyanTanev merged 2 commits into
mainfrom
kalo/fix-proxy-metrics

Conversation

@KaloyanTanev

Copy link
Copy Markdown
Collaborator

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

category: bug
ticket: none

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

codecov Bot commented Jun 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 57.03%. Comparing base (9a39a98) to head (d9cd27b).
⚠️ Report is 2 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread core/validatorapi/metrics.go Outdated
@KaloyanTanev KaloyanTanev enabled auto-merge (squash) June 8, 2026 16:35
@sonarqubecloud

sonarqubecloud Bot commented Jun 8, 2026

Copy link
Copy Markdown

@KaloyanTanev KaloyanTanev merged commit 576c67b into main Jun 8, 2026
9 of 10 checks passed
@KaloyanTanev KaloyanTanev deleted the kalo/fix-proxy-metrics branch June 8, 2026 16:45
pinebit added a commit that referenced this pull request Jun 9, 2026
Cherry-picked:
* rework deadliner #4552
* core/validatorapi: fix dynamic path proxy metric #4553
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.

3 participants