From bf4e5d4d2ca33da46d0cec11eea229684fa7ae4d Mon Sep 17 00:00:00 2001 From: Amar Singh Date: Thu, 9 Jul 2020 15:01:49 -0400 Subject: [PATCH] add ios to cfg gates in client/service (#6622) * done * sysinfo should not be not android * add back sysinfo dep to satisfy web wasm ci --- substrate/client/service/Cargo.toml | 3 +-- substrate/client/service/src/metrics.rs | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/substrate/client/service/Cargo.toml b/substrate/client/service/Cargo.toml index c55c1cc57a..caf2360892 100644 --- a/substrate/client/service/Cargo.toml +++ b/substrate/client/service/Cargo.toml @@ -76,8 +76,7 @@ sc-tracing = { version = "2.0.0-rc4", path = "../tracing" } tracing = "0.1.10" parity-util-mem = { version = "0.7.0", default-features = false, features = ["primitive-types"] } - -[target.'cfg(all(any(unix, windows), not(target_os = "android")))'.dependencies] +[target.'cfg(all(any(unix, windows), not(target_os = "android"), not(target_os = "ios")))'.dependencies] netstat2 = "0.8.1" [target.'cfg(target_os = "linux")'.dependencies] diff --git a/substrate/client/service/src/metrics.rs b/substrate/client/service/src/metrics.rs index 1727aaae74..c9726e8e36 100644 --- a/substrate/client/service/src/metrics.rs +++ b/substrate/client/service/src/metrics.rs @@ -29,14 +29,14 @@ use sc_network::config::Role; use sysinfo::{self, ProcessExt, SystemExt}; -#[cfg(all(any(unix, windows), not(target_os = "android")))] +#[cfg(all(any(unix, windows), not(target_os = "android"), not(target_os = "ios")))] use netstat2::{ TcpState, ProtocolSocketInfo, iterate_sockets_info, AddressFamilyFlags, ProtocolFlags, }; struct PrometheusMetrics { // system - #[cfg(all(any(unix, windows), not(target_os = "android")))] + #[cfg(all(any(unix, windows), not(target_os = "android"), not(target_os = "ios")))] load_avg: GaugeVec, // process @@ -45,7 +45,7 @@ struct PrometheusMetrics { threads: Gauge, open_files: GaugeVec, - #[cfg(all(any(unix, windows), not(target_os = "android")))] + #[cfg(all(any(unix, windows), not(target_os = "android"), not(target_os = "ios")))] netstat: GaugeVec, // -- inner counters @@ -89,7 +89,7 @@ impl PrometheusMetrics { Ok(Self { // system - #[cfg(all(any(unix, windows), not(target_os = "android")))] + #[cfg(all(any(unix, windows), not(target_os = "android"), not(target_os = "ios")))] load_avg: register(GaugeVec::new( Opts::new("load_avg", "System load average"), &["over"] @@ -104,7 +104,7 @@ impl PrometheusMetrics { "cpu_usage_percentage", "Node CPU usage", )?, registry)?, - #[cfg(all(any(unix, windows), not(target_os = "android")))] + #[cfg(all(any(unix, windows), not(target_os = "android"), not(target_os = "ios")))] netstat: register(GaugeVec::new( Opts::new("netstat_tcp", "Current TCP connections "), &["status"] @@ -154,7 +154,7 @@ impl PrometheusMetrics { } } -#[cfg(all(any(unix, windows), not(target_os = "android")))] +#[cfg(all(any(unix, windows), not(target_os = "android"), not(target_os = "ios")))] #[derive(Default)] struct ConnectionsCount { listen: u64, @@ -186,7 +186,7 @@ struct ProcessInfo { pub struct MetricsService { metrics: Option, - #[cfg(all(any(unix, windows), not(target_os = "android")))] + #[cfg(all(any(unix, windows), not(target_os = "android"), not(target_os = "ios")))] system: sysinfo::System, pid: Option, } @@ -229,7 +229,7 @@ impl MetricsService { } } -#[cfg(all(any(unix, windows), not(target_os = "android"), not(target_os = "linux")))] +#[cfg(all(any(unix, windows), not(target_os = "android"), not(target_os = "ios"), not(target_os = "linux")))] impl MetricsService { fn inner_new(metrics: Option) -> Self { Self { @@ -245,7 +245,7 @@ impl MetricsService { } -#[cfg(not(all(any(unix, windows), not(target_os = "android"))))] +#[cfg(not(all(any(unix, windows), not(target_os = "android"), not(target_os = "ios"))))] impl MetricsService { fn inner_new(metrics: Option) -> Self { Self { @@ -280,7 +280,7 @@ impl MetricsService { Self::inner_new(None) } - #[cfg(all(any(unix, windows), not(target_os = "android")))] + #[cfg(all(any(unix, windows), not(target_os = "android"), not(target_os = "ios")))] fn process_info_for(&mut self, pid: &sysinfo::Pid) -> ProcessInfo { let mut info = ProcessInfo::default(); if self.system.refresh_process(*pid) { @@ -292,7 +292,7 @@ impl MetricsService { info } - #[cfg(all(any(unix, windows), not(target_os = "android")))] + #[cfg(all(any(unix, windows), not(target_os = "android"), not(target_os = "ios")))] fn connections_info(&self) -> Option { self.pid.as_ref().and_then(|pid| { let af_flags = AddressFamilyFlags::IPV4 | AddressFamilyFlags::IPV6; @@ -423,7 +423,7 @@ impl MetricsService { ); } - #[cfg(all(any(unix, windows), not(target_os = "android")))] + #[cfg(all(any(unix, windows), not(target_os = "android"), not(target_os = "ios")))] { let load = self.system.get_load_average(); metrics.load_avg.with_label_values(&["1min"]).set(load.one);