Skip to content

Commit

Permalink
update the latency calc to use local time now (#250)
Browse files Browse the repository at this point in the history
  • Loading branch information
larry-aptos authored Jan 25, 2024
1 parent 1b28ab1 commit 6d2b780
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions rust/indexer-metrics/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ async fn start_processor_status_fetch(url: String, chain_name: String) {
Ok(resp) => {
tracing::info!(url = &url, response = ?resp, "Request succeeded");
// Process the data as needed
let system_time_now = chrono::Utc::now().naive_utc();
for processor in resp.processor_status {
HASURA_API_LATEST_VERSION
.with_label_values(&[&processor.processor, &chain_name])
Expand All @@ -156,13 +157,10 @@ async fn start_processor_status_fetch(url: String, chain_name: String) {
processor.last_transaction_timestamp.timestamp_micros() as f64
* 1e-6,
);
let latency = system_time_now - processor.last_transaction_timestamp;
HASURA_API_LATEST_TRANSACTION_LATENCY_IN_SECS
.with_label_values(&[&processor.processor, &chain_name])
.set(
(processor.last_updated - processor.last_transaction_timestamp)
.num_milliseconds() as f64
* 1e-3,
);
.set(latency.num_milliseconds() as f64 * 1e-3);
}
},
Err(err) => {
Expand Down

0 comments on commit 6d2b780

Please sign in to comment.