Skip to content

Commit

Permalink
remove logging and add metric
Browse files Browse the repository at this point in the history
  • Loading branch information
ppca committed Oct 10, 2024
1 parent 2eb8859 commit 0bece62
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 31 deletions.
32 changes: 14 additions & 18 deletions chain-signatures/node/src/mesh/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,13 @@ impl Pool {
continue;
};

tracing::debug!(
"going to send /state call to {:?} url {} /state",
participant,
info.url
);
let Ok(resp) = self.http.get(url.clone()).timeout(Duration::from_secs(2)).send().await else {
tracing::debug!(
"finish send /state call to {:?} url {} /state",
participant,
info.url
);
let Ok(resp) = self
.http
.get(url.clone())
.timeout(Duration::from_secs(2))
.send()
.await
else {
tracing::warn!(
"Pool.ping resp err participant {:?} url {}",
participant,
Expand All @@ -68,12 +64,6 @@ impl Pool {
continue;
};

tracing::debug!(
"finish send /state call to {:?} url {} /state",
participant,
info.url
);

let Ok(state): Result<StateView, _> = resp.json().await else {
tracing::warn!(
"Pool.ping state view err participant {:?} url {}",
Expand Down Expand Up @@ -109,7 +99,13 @@ impl Pool {
continue;
};

let Ok(resp) = self.http.get(url).timeout(Duration::from_secs(2)).send().await else {
let Ok(resp) = self
.http
.get(url)
.timeout(Duration::from_secs(2))
.send()
.await
else {
continue;
};

Expand Down
12 changes: 6 additions & 6 deletions chain-signatures/node/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,19 +389,19 @@ pub(crate) static SIGNATURE_PUBLISH_FAILURES: Lazy<CounterVec> = Lazy::new(|| {
.unwrap()
});

pub(crate) static PROTOCOL_LATENCY_ITER_CNT: Lazy<CounterVec> = Lazy::new(|| {
pub(crate) static SIGNATURE_PUBLISH_RESPONSE_ERRORS: Lazy<CounterVec> = Lazy::new(|| {
try_create_counter_vec(
"multichain_protocol_iter_count",
"Count of multichain protocol iter",
"multichain_signature_publish_response_errors",
"number of respond calls with response that cannot be converted to json",
&["node_account_id"],
)
.unwrap()
});

pub(crate) static SIGNATURE_PUBLISH_RESPONSE_ERRORS: Lazy<CounterVec> = Lazy::new(|| {
pub(crate) static PROTOCOL_LATENCY_ITER_CNT: Lazy<CounterVec> = Lazy::new(|| {
try_create_counter_vec(
"multichain_signature_publish_response_errors",
"number of respond calls with response that cannot be converted to json",
"multichain_protocol_iter_count",
"Count of multichain protocol iter",
&["node_account_id"],
)
.unwrap()
Expand Down
8 changes: 1 addition & 7 deletions chain-signatures/node/src/protocol/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ impl MpcSignProtocol {
crate::metrics::PROTOCOL_LATENCY_ITER_CNT
.with_label_values(&[my_account_id.as_str()])
.inc();

loop {
let msg_result = self.receiver.try_recv();
match msg_result {
Expand Down Expand Up @@ -287,22 +288,15 @@ impl MpcSignProtocol {
}

if last_pinged.elapsed() > Duration::from_millis(300) {
tracing::debug!("doing ping now");
let start = Instant::now();
self.ctx.mesh.ping().await;
let ping_latency = start.elapsed().as_secs();
tracing::debug!("ping latency was {ping_latency} seconds");
last_pinged = Instant::now();
}

tracing::debug!("finish ping now");

let state = {
let guard = self.state.read().await;
guard.clone()
};

tracing::debug!("finish reading state now");
let crypto_time = Instant::now();
let mut state = match state.progress(&mut self).await {
Ok(state) => {
Expand Down

0 comments on commit 0bece62

Please sign in to comment.