Skip to content

Commit

Permalink
fixed: histograms metrics to seconds (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
giangndm authored Jun 27, 2024
1 parent ec45b1d commit 48773a4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion crates/relayer/src/agent_listener/quic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl<REQ: DeserializeOwned + Debug> AgentQuicListener<REQ> {
match Self::process_incoming_conn(cluster_validator, conn).await {
Ok(connection) => {
histogram!(METRICS_AGENT_HISTOGRAM)
.record(started.elapsed().as_millis() as f32);
.record(started.elapsed().as_millis() as f32 / 1000.0);
log::info!("new connection {}", connection.domain());
if let Err(e) = tx.send(connection).await {
log::error!("send new connection to main loop error {:?}", e);
Expand Down
2 changes: 1 addition & 1 deletion crates/relayer/src/agent_listener/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl<
match self.process_incoming_stream(stream).await {
Ok(connection) => {
histogram!(METRICS_AGENT_HISTOGRAM)
.record(started.elapsed().as_millis() as f32);
.record(started.elapsed().as_millis() as f32 / 1000.0);
log::info!("new connection {}", connection.domain());
return Ok(connection);
}
Expand Down
3 changes: 2 additions & 1 deletion crates/relayer/src/agent_worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ where
counter!(METRICS_TUNNEL_AGENT_COUNT).increment(1);
let started = Instant::now();
let sub_connection = self.connection.create_sub_connection().await?;
histogram!(METRICS_TUNNEL_AGENT_HISTOGRAM).record(started.elapsed().as_millis() as f32);
histogram!(METRICS_TUNNEL_AGENT_HISTOGRAM)
.record(started.elapsed().as_millis() as f32 / 1000.0);

async_std::task::spawn(async move {
if conn.local() {
Expand Down
3 changes: 2 additions & 1 deletion crates/relayer/src/tunnel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ async fn tunnel_over_cluster<'a>(
let (mut send, mut recv) = connection.open_bi().await?;
log::info!("opened bi stream to agent for domain: {domain} in node {dest}");

histogram!(METRICS_TUNNEL_CLUSTER_HISTOGRAM).record(started.elapsed().as_millis() as f32);
histogram!(METRICS_TUNNEL_CLUSTER_HISTOGRAM)
.record(started.elapsed().as_millis() as f32 / 1000.0);

let req_buf: Vec<u8> = (&ClusterTunnelRequest {
domain: domain.clone(),
Expand Down

0 comments on commit 48773a4

Please sign in to comment.