Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Metrics] Track synced blocks. #3231

Merged
merged 3 commits into from Apr 24, 2024
Merged

[Metrics] Track synced blocks. #3231

merged 3 commits into from Apr 24, 2024

Conversation

d0cd
Copy link
Contributor

@d0cd d0cd commented Apr 22, 2024

This PR introduces a metric to track the number of blocks added through syncing.

@@ -461,6 +461,9 @@ impl<N: Network> BlockSync<N> {
let is_synced = num_blocks_behind <= max_blocks_behind;
// Update the sync status.
self.is_block_synced.store(is_synced, Ordering::SeqCst);
// Update the `IS_SYNCED` metric.
#[cfg(feature = "metrics")]
metrics::gauge(metrics::bft::IS_SYNCED, is_synced);
Copy link
Contributor

@miazn miazn Apr 22, 2024

Choose a reason for hiding this comment

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

This looks good! One thing that might make a difference in recording is that metrics are "registered" before they are seen, which basically initializes all metrics in the names folder at 0. Its probably a trivial difference, as for this metric we initialize it and then update sync status pretty quickly, however just wanted to point out that it will be initialized at 0. If we only want to start recording the metric the first time this line of code is hit, the metric name should be removed from the names.rs file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it should be fine since is_block_synced is initialized with Default::default() == false. So we'll have the property that is_block_synced matches IS_SYNCED.

Copy link
Contributor

Choose a reason for hiding this comment

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

Doesnt it update when its initializing the sync module? I think it should reflect the current state 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

@miazn - reading further, this does get triggered with the sync is initialized. You're right.

@d0cd d0cd marked this pull request as ready for review April 23, 2024 17:50
@howardwu howardwu merged commit 6157b45 into mainnet-staging Apr 24, 2024
24 checks passed
@howardwu howardwu deleted the feat/sync-metrics branch April 24, 2024 21:52
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.

None yet

4 participants