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

Commit

Permalink
use parking_lot::Mutex
Browse files Browse the repository at this point in the history
  • Loading branch information
adria0 committed Jul 18, 2020
1 parent 19b7279 commit 14598b3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions parity/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
use std::{
time::Instant,
sync::{Mutex, Arc}
sync::Arc
};

use crate::{
rpc,
rpc_apis
};

use parking_lot::Mutex;

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

let state = state.lock().unwrap();
let state = state.lock();

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

drop(state);

let elapsed = start.elapsed();
let ms = (elapsed.as_secs() as i64)*1000 + (elapsed.subsec_millis() as i64);
prometheus_gauge(&mut reg, "metrics_time", "Time to perform rpc metrics", ms);
Expand Down

0 comments on commit 14598b3

Please sign in to comment.