Skip to content

Commit

Permalink
Standardize latency metrics to ms (linera-io#1523)
Browse files Browse the repository at this point in the history
## Motivation

All latency metrics should be in ms

## Proposal

Do that

## Test Plan

Ran e2e tests locally, saw metrics logged with higher ms amounts
  • Loading branch information
Andre da Silva authored Jan 19, 2024
1 parent b55d491 commit a58c59d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
6 changes: 3 additions & 3 deletions linera-chain/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ pub static BLOCK_EXECUTION_LATENCY: Lazy<HistogramVec> = Lazy::new(|| {
"Block execution latency",
&[],
vec![
0.000_01, 0.000_03, 0.000_1, 0.000_25, 0.000_5, 0.001, 0.002_5, 0.005, 0.01, 0.025,
0.05, 0.1, 0.25, 0.5, 1.0, 2.0, 5.0,
0.000_1, 0.000_25, 0.000_5, 0.001, 0.002_5, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5,
1.0, 2.5, 5.0, 10.0, 25.0, 50.0
],
)
.expect("Counter creation should not fail")
Expand Down Expand Up @@ -764,7 +764,7 @@ where
NUM_BLOCKS_EXECUTED.with_label_values(&[]).inc();
BLOCK_EXECUTION_LATENCY
.with_label_values(&[])
.observe(start_time.elapsed().as_secs_f64());
.observe(start_time.elapsed().as_millis() as f64);
WASM_FUEL_USED_PER_BLOCK
.with_label_values(&[])
.observe(tracker.used_fuel as f64);
Expand Down
16 changes: 11 additions & 5 deletions linera-rpc/src/grpc_network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,13 @@ type CrossChainSender = mpsc::Sender<(linera_core::data_types::CrossChainRequest
type NotificationSender = mpsc::Sender<Notification>;

pub static SERVER_REQUEST_LATENCY: Lazy<HistogramVec> = Lazy::new(|| {
register_histogram_vec!("server_request_latency", "Server request latency", &[])
.expect("Counter creation should not fail")
register_histogram_vec!(
"server_request_latency",
"Server request latency",
&[],
vec![0.5, 1.0, 2.5, 5.0, 10.0, 25.0, 50.0]
)
.expect("Counter creation should not fail")
});

pub static SERVER_REQUEST_COUNT: Lazy<IntCounterVec> = Lazy::new(|| {
Expand Down Expand Up @@ -100,7 +105,8 @@ pub static SERVER_REQUEST_LATENCY_PER_REQUEST_TYPE: Lazy<HistogramVec> = Lazy::n
register_histogram_vec!(
"server_request_latency_per_request_type",
"Server request latency per request type",
&["method_name"]
&["method_name"],
vec![0.5, 1.0, 2.5, 5.0, 10.0, 25.0, 50.0]
)
.expect("Counter creation should not fail")
});
Expand Down Expand Up @@ -182,7 +188,7 @@ where
let response = future.await?;
SERVER_REQUEST_LATENCY
.with_label_values(&[])
.observe(start.elapsed().as_secs_f64());
.observe(start.elapsed().as_millis() as f64);
SERVER_REQUEST_COUNT.with_label_values(&[]).inc();
Ok(response)
}
Expand Down Expand Up @@ -423,7 +429,7 @@ where
fn log_request_success_and_latency(start: Instant, method_name: &str) {
SERVER_REQUEST_LATENCY_PER_REQUEST_TYPE
.with_label_values(&[method_name])
.observe(start.elapsed().as_secs_f64());
.observe(start.elapsed().as_millis() as f64);
SERVER_REQUEST_SUCCESS
.with_label_values(&[method_name])
.inc();
Expand Down
14 changes: 11 additions & 3 deletions linera-service/src/grpc_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,16 @@ use tower::{builder::ServiceBuilder, Layer, Service};
use tracing::{debug, info, instrument};

pub static PROXY_REQUEST_LATENCY: Lazy<HistogramVec> = Lazy::new(|| {
register_histogram_vec!("proxy_request_latency", "Proxy request latency", &[])
.expect("Counter creation should not fail")
register_histogram_vec!(
"proxy_request_latency",
"Proxy request latency",
&[],
vec![
0.001, 0.002_5, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0, 10.0, 25.0,
50.0, 100.0, 200.0, 300.0, 400.0
]
)
.expect("Counter creation should not fail")
});

pub static PROXY_REQUEST_COUNT: Lazy<IntCounterVec> = Lazy::new(|| {
Expand Down Expand Up @@ -105,7 +113,7 @@ where
let response = future.await?;
PROXY_REQUEST_LATENCY
.with_label_values(&[])
.observe(start.elapsed().as_secs_f64());
.observe(start.elapsed().as_millis() as f64);
PROXY_REQUEST_COUNT.with_label_values(&[]).inc();
Ok(response)
}
Expand Down

0 comments on commit a58c59d

Please sign in to comment.