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

bugfix(op-node): fix the issue of inaccurate peerCount Metric #49

Merged
merged 1 commit into from
Sep 20, 2023

Conversation

welkin22
Copy link
Contributor

@welkin22 welkin22 commented Sep 18, 2023

Background

When we use DNS to specify the addresses of staticPeers, there may be a situation where one peer corresponds to multiple connections. Therefore, the same peer may trigger the Connected or the Disconnected event of Notifiee multiple times. This will cause inaccurate peerCount statistics. In addition, restarting the op-node service may also cause statistical problems. Because peerCount is a gauge type indicator, if the Disconnected event cannot be processed in time when the service is closed, peerCount may retain incorrect data and will not decrease to 0.

Solution

In order to minimize the impact of duplicate events and server restarts, we should use Gauge.Set(float64) instead of the currently used Inc*() and Dec*() methods. Getting the length of the peers array stored in the Network object each time will make the statistical indicators more accurate.

@welkin22 welkin22 changed the title bugfix: fix the issue of inaccurate peerCount Metric bugfix(op-node): fix the issue of inaccurate peerCount Metric Sep 18, 2023
@welkin22 welkin22 merged commit a1f92fd into bnb-chain:develop Sep 20, 2023
1 check passed
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.

2 participants