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

network:bridge: fix peer_count metric #3711

Merged
merged 5 commits into from
Apr 1, 2024

Conversation

alexggh
Copy link
Contributor

@alexggh alexggh commented Mar 15, 2024

The metric records the current protocol_version of the validator that just connected with the peer_map.len(), which contains all peers that connected, that has the effect the metric will be wrong since it won't tell us how many peers we have connected per version because it will always record the total number of peers

Fix this by counting by version inside peer_map, additionally because that might be a bit heavier than len(), publish it only on-active leaves.

alexggh added 3 commits March 15, 2024 13:07
The metric records the current protocol_version of the validator that just
connected with the peer_map.len(), which contains all peers that
connected, that has the effect the metric will be wrong since it won't
tell us how many peers we have connected per version because it will
always record the total number of peers

Signed-off-by: Alexandru Gheorghe <alexandru.gheorghe@parity.io>
Signed-off-by: Alexandru Gheorghe <alexandru.gheorghe@parity.io>
@alexggh alexggh added the R0-silent Changes should not be mentioned in any release notes label Mar 29, 2024
Signed-off-by: Alexandru Gheorghe <alexandru.gheorghe@parity.io>
@alexggh alexggh marked this pull request as ready for review March 29, 2024 14:09
@alexggh alexggh changed the title Fix peer_count metric network:bridge: fix peer_count metric Mar 29, 2024
Copy link
Member

@ordian ordian left a comment

Choose a reason for hiding this comment

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

This will delay updating the metric until the next block is produced, but it seems reasonable. If that is proven to be heavy/causing issues, we could put the by_version_count into the (metrics) state and do incremental updates as before.

@ordian ordian added the T0-node This PR/Issue is related to the topic “node”. label Mar 30, 2024
@alexggh
Copy link
Contributor Author

alexggh commented Apr 1, 2024

If that is proven to be heavy/causing issues, we could put the by_version_count into the (metrics) state and do incremental updates as before.

Yeah, that would be a bit more intrusive, so I decided it is not worth it.

This will delay updating the metric until the next block is produced, but it seems reasonable.

It is not chaning the behaviour much, because metrics are collected by prometheus at intervals higher than 6s, so even if you update every 10ms, you would still collect only the last updated count.

@alexggh alexggh added this pull request to the merge queue Apr 1, 2024
Merged via the queue into master with commit e0c081d Apr 1, 2024
136 of 139 checks passed
@alexggh alexggh deleted the alexaggh/fix_peer_count_by_version branch April 1, 2024 06:50
pgherveou pushed a commit that referenced this pull request Apr 2, 2024
The metric records the current protocol_version of the validator that
just connected with the peer_map.len(), which contains all peers that
connected, that has the effect the metric will be wrong since it won't
tell us how many peers we have connected per version because it will
always record the total number of peers

Fix this by counting by version inside peer_map, additionally because
that might be a bit heavier than len(), publish it only on-active
leaves.

---------

Signed-off-by: Alexandru Gheorghe <alexandru.gheorghe@parity.io>
Ank4n pushed a commit that referenced this pull request Apr 9, 2024
The metric records the current protocol_version of the validator that
just connected with the peer_map.len(), which contains all peers that
connected, that has the effect the metric will be wrong since it won't
tell us how many peers we have connected per version because it will
always record the total number of peers

Fix this by counting by version inside peer_map, additionally because
that might be a bit heavier than len(), publish it only on-active
leaves.

---------

Signed-off-by: Alexandru Gheorghe <alexandru.gheorghe@parity.io>
dharjeezy pushed a commit to dharjeezy/polkadot-sdk that referenced this pull request Apr 9, 2024
The metric records the current protocol_version of the validator that
just connected with the peer_map.len(), which contains all peers that
connected, that has the effect the metric will be wrong since it won't
tell us how many peers we have connected per version because it will
always record the total number of peers

Fix this by counting by version inside peer_map, additionally because
that might be a bit heavier than len(), publish it only on-active
leaves.

---------

Signed-off-by: Alexandru Gheorghe <alexandru.gheorghe@parity.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
R0-silent Changes should not be mentioned in any release notes T0-node This PR/Issue is related to the topic “node”.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants