Skip to content

feat: size metrics for chain follower internal hash maps#7131

Merged
hanabi1224 merged 1 commit into
mainfrom
hm/metrics-for-chain-follower-hashmaps
Jun 2, 2026
Merged

feat: size metrics for chain follower internal hash maps#7131
hanabi1224 merged 1 commit into
mainfrom
hm/metrics-for-chain-follower-hashmaps

Conversation

@hanabi1224

@hanabi1224 hanabi1224 commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Summary of changes

Changes introduced in this pull request:

# HELP chain_follower_tasks_size_bytes Size of the chain follower tasks in bytes
# TYPE chain_follower_tasks_size_bytes gauge
# UNIT chain_follower_tasks_size_bytes bytes
chain_follower_tasks_size_bytes 544
# HELP chain_follower_tasks_len Length of the chain follower tasks
# TYPE chain_follower_tasks_len gauge
chain_follower_tasks_len 1
# HELP chain_follower_tasks_cap Capacity of the chain follower tasks
# TYPE chain_follower_tasks_cap gauge
chain_follower_tasks_cap 14
# HELP chain_follower_tipsets_size_bytes Size of the chain follower tipsets in bytes
# TYPE chain_follower_tipsets_size_bytes gauge
# UNIT chain_follower_tipsets_size_bytes bytes
chain_follower_tipsets_size_bytes 83984
# HELP chain_follower_tipsets_len Length of the chain follower tipsets
# TYPE chain_follower_tipsets_len gauge
chain_follower_tipsets_len 67
# HELP chain_follower_tipsets_cap Capacity of the chain follower tipsets
# TYPE chain_follower_tipsets_cap gauge
chain_follower_tipsets_cap 1772

Reference issue to close (if applicable)

Closes

Other information and links

Change checklist

  • I have performed a self-review of my own code,
  • I have made corresponding changes to the documentation. All new code adheres to the team's documentation standards,
  • I have added tests that prove my fix is effective or that my feature works (if possible),
  • I have made sure the CHANGELOG is up-to-date. All user-facing changes should be reflected in this document.

Outside contributions

  • I have read and agree to the CONTRIBUTING document.
  • I have read and agree to the AI Policy document. I understand that failure to comply with the guidelines will lead to rejection of the pull request.

Summary by CodeRabbit

Release Notes

  • Monitoring & Observability
    • Introduced Prometheus metrics collectors for chain synchronization tasks and state-machine operations with detailed monitoring capabilities.
    • New gauges expose allocation size, data structure length, and capacity metrics for internal synchronization components.
    • Enhanced metrics coverage provides comprehensive visibility into synchronization task performance and internal resource utilization patterns.

@hanabi1224 hanabi1224 added the RPC requires calibnet RPC checks to run on CI label Jun 2, 2026
@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 4f2defad-516c-4762-9daf-17052b8a92b9

📥 Commits

Reviewing files that changed from the base of the PR and between a79a337 and 1702561.

📒 Files selected for processing (1)
  • src/chain_sync/chain_follower.rs

Walkthrough

This PR adds Prometheus metrics instrumentation to the chain synchronization module. It updates imports, decorates the state machine with custom debug output, introduces wrapper types that implement the Collector trait to expose internal container metrics, and registers these collectors during ChainFollower initialization.

Changes

Synchronization metrics instrumentation

Layer / File(s) Summary
Imports and state machine debug annotation
src/chain_sync/chain_follower.rs
Import adjustments add chrono::Utc and hashbrown types; SyncStateMachine gains a derive_more::Debug derive that skips bad_block_cache from debug output.
Collector implementation for synchronization metrics
src/chain_sync/chain_follower.rs
SyncTasks and SyncStateMachineWrapper wrapper types implement prometheus_client::Collector to expose gauges for allocation size, length, and capacity of internal HashSet and HashMap collections.
Metrics registration in ChainFollower
src/chain_sync/chain_follower.rs
Prometheus collectors are registered during ChainFollower::new for the sync task set and wrapped state machine, exposing chain follower gauge metrics.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • akaladarshi
  • LesnyRumcajs
  • sudo-shashank
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: adding Prometheus metrics for sizes of internal HashMaps and HashSets in the ChainFollower component.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch hm/metrics-for-chain-follower-hashmaps
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch hm/metrics-for-chain-follower-hashmaps

Comment @coderabbitai help to get the list of available commands and usage tips.

@hanabi1224 hanabi1224 marked this pull request as ready for review June 2, 2026 12:22
@hanabi1224 hanabi1224 requested a review from a team as a code owner June 2, 2026 12:22
@hanabi1224 hanabi1224 requested review from LesnyRumcajs and sudo-shashank and removed request for a team June 2, 2026 12:22
@codecov

codecov Bot commented Jun 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 5.26316% with 72 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.34%. Comparing base (a79a337) to head (1702561).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/chain_sync/chain_follower.rs 5.26% 72 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
src/chain_sync/chain_follower.rs 33.37% <5.26%> (-2.90%) ⬇️

... and 4 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a79a337...1702561. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hanabi1224 hanabi1224 added this pull request to the merge queue Jun 2, 2026
Merged via the queue into main with commit 39a6969 Jun 2, 2026
39 of 62 checks passed
@hanabi1224 hanabi1224 deleted the hm/metrics-for-chain-follower-hashmaps branch June 2, 2026 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RPC requires calibnet RPC checks to run on CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants