Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.

Commit 14598b3

Browse files
author
adria0
committed
use parking_lot::Mutex
1 parent 19b7279 commit 14598b3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

parity/metrics.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
use std::{
22
time::Instant,
3-
sync::{Mutex, Arc}
3+
sync::Arc
44
};
55

66
use crate::{
77
rpc,
88
rpc_apis
99
};
1010

11+
use parking_lot::Mutex;
12+
1113
use hyper::{
1214
Method, Body, Request, Response, Server, StatusCode,
1315
service::{make_service_fn, service_fn}
@@ -50,11 +52,13 @@ fn handle_request(req: Request<Body>, state: &Arc<Mutex<State>>) -> Response<Bod
5052
let start = Instant::now();
5153
let mut reg = prometheus::Registry::new();
5254

53-
let state = state.lock().unwrap();
55+
let state = state.lock();
5456

5557
state.rpc_apis.client.prometheus_metrics(&mut reg);
5658
state.rpc_apis.sync.prometheus_metrics(&mut reg);
5759

60+
drop(state);
61+
5862
let elapsed = start.elapsed();
5963
let ms = (elapsed.as_secs() as i64)*1000 + (elapsed.subsec_millis() as i64);
6064
prometheus_gauge(&mut reg, "metrics_time", "Time to perform rpc metrics", ms);

0 commit comments

Comments
 (0)