Skip to content

network:bridge: fix peer_count metric#3711

Merged
alexggh merged 5 commits intomasterfrom
alexaggh/fix_peer_count_by_version
Apr 1, 2024
Merged

network:bridge: fix peer_count metric#3711
alexggh merged 5 commits intomasterfrom
alexaggh/fix_peer_count_by_version

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 <[email protected]>
Signed-off-by: Alexandru Gheorghe <[email protected]>
@alexggh alexggh added the R0-no-crate-publish-required The change does not require any crates to be re-published. label Mar 29, 2024
Signed-off-by: Alexandru Gheorghe <[email protected]>
@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
Contributor

@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
@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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

R0-no-crate-publish-required The change does not require any crates to be re-published. 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