Match substrate's fmt (#1148)

* Alter gitlab.

* Use substrate's rustfmt.toml

* cargo +nightly fmt --all

* Fix spellcheck.

* cargo +nightly fmt --all

* format.

* Fix spellcheck and fmt

* fmt?

* Fix spellcheck

Co-authored-by: Tomasz Drwięga <tomasz@parity.io>
This commit is contained in:
hacpy
2021-09-24 19:29:31 +08:00
committed by Bastian Köcher
parent 87cbb382d9
commit bd70de8b8b
174 changed files with 6095 additions and 4962 deletions
@@ -14,7 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
use crate::metrics::{metric_name, register, F64SharedRef, Gauge, PrometheusError, Registry, StandaloneMetrics, F64};
use crate::metrics::{
metric_name, register, F64SharedRef, Gauge, PrometheusError, Registry, StandaloneMetrics, F64,
};
use async_std::sync::{Arc, RwLock};
use async_trait::async_trait;
@@ -100,18 +102,12 @@ impl StandaloneMetrics for FloatJsonValueMetric {
/// Parse HTTP service response.
fn parse_service_response(json_path: &str, response: &str) -> Result<f64, String> {
let json = serde_json::from_str(response).map_err(|err| {
format!(
"Failed to parse HTTP service response: {:?}. Response: {:?}",
err, response,
)
format!("Failed to parse HTTP service response: {:?}. Response: {:?}", err, response,)
})?;
let mut selector = jsonpath_lib::selector(&json);
let maybe_selected_value = selector(json_path).map_err(|err| {
format!(
"Failed to select value from response: {:?}. Response: {:?}",
err, response,
)
format!("Failed to select value from response: {:?}. Response: {:?}", err, response,)
})?;
let selected_value = maybe_selected_value
.first()
@@ -121,7 +117,7 @@ fn parse_service_response(json_path: &str, response: &str) -> Result<f64, String
return Err(format!(
"Failed to parse float value {:?} from response. It is assumed to be positive and normal",
selected_value,
));
))
}
Ok(selected_value)
+13 -6
View File
@@ -17,7 +17,8 @@
//! Global system-wide Prometheus metrics exposed by relays.
use crate::metrics::{
metric_name, register, Gauge, GaugeVec, Opts, PrometheusError, Registry, StandaloneMetrics, F64, U64,
metric_name, register, Gauge, GaugeVec, Opts, PrometheusError, Registry, StandaloneMetrics,
F64, U64,
};
use async_std::sync::{Arc, Mutex};
@@ -50,7 +51,10 @@ impl GlobalMetrics {
registry,
)?,
process_cpu_usage_percentage: register(
Gauge::new(metric_name(prefix, "process_cpu_usage_percentage"), "Process CPU usage")?,
Gauge::new(
metric_name(prefix, "process_cpu_usage_percentage"),
"Process CPU usage",
)?,
registry,
)?,
process_memory_usage_bytes: register(
@@ -92,16 +96,19 @@ impl StandaloneMetrics for GlobalMetrics {
memory_usage,
);
self.process_cpu_usage_percentage
.set(if cpu_usage.is_finite() { cpu_usage } else { 0f64 });
self.process_cpu_usage_percentage.set(if cpu_usage.is_finite() {
cpu_usage
} else {
0f64
});
self.process_memory_usage_bytes.set(memory_usage);
}
},
_ => {
log::warn!(
target: "bridge-metrics",
"Failed to refresh process information. Metrics may show obsolete values",
);
}
},
}
}