Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Fix the cfg guards in service/metrics.rs #5770

Merged
merged 1 commit into from
Apr 24, 2020

Conversation

tomaka
Copy link
Contributor

@tomaka tomaka commented Apr 24, 2020

cc paritytech/polkadot#1027

As a general remark, I'm really not a fan of having platform-specific code, as it tends to derail over time into a clusterfuck of unmaintainable cfg guards. To me, metrics such as the CPU usage, threads, number of TCP connections, etc. should be reported by another process running on the side of the node.

Anyway. The point of this PR is to remove the dependency on netstat2 for Android, since it fails to compile.
The metrics about the network statistics are already reported in cross-platform way by the sc_network crate, so someone who would like to monitor an Android node won't lose any information.

I've also slightly refactored the cfg(target_os = "unknown") guards, because assuming that not(any(unix, windows)) is the same as target_os = "unknown" will likely bite us in the future.

@tomaka tomaka added A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes labels Apr 24, 2020
@bkchr
Copy link
Member

bkchr commented Apr 24, 2020

If sc_network is reporting the networking statistics already, can we not remove them here?

@gnunicorn
Copy link
Contributor

If sc_network is reporting the networking statistics already, can we not remove them here?

If they are, we really should remove the usage of netstat2 altogether and tracking from here. However, just to be sure, the sc_network metrics are tracking all sockets and ports, also not opened via libp2p but for e.g. over RPC? Because that is what the netstat2-based tests allows to check for: the systems black-box answer to the questions ...

Copy link
Contributor

@gnunicorn gnunicorn left a comment

Choose a reason for hiding this comment

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

yay, complexity in cfg( attrs :D ...

all good though.

@tomaka
Copy link
Contributor Author

tomaka commented Apr 24, 2020

also not opened via libp2p but for e.g. over RPC?

Indeed it doesn't.

The other motivation for keeping netstat2 is also to compare against the number that libp2p reports and detect any anomaly (as it has happened a couple weeks ago). But IMO this isn't necessarily a good idea: we can't just starting doubling every metric just in case there's a bug somewhere.

@gnunicorn gnunicorn merged commit 47b304d into paritytech:master Apr 24, 2020
@tomaka tomaka deleted the fix-cfg-guards branch April 24, 2020 15:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants