Skip to content

Commit

Permalink
[Metrics] Add last_decided_time (EspressoSystems#2577)
Browse files Browse the repository at this point in the history
* add last_decided_time

* lint
  • Loading branch information
dailinsubjam authored Feb 15, 2024
1 parent bde7f95 commit 6f02c0d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions task-impls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ bitvec = { workspace = true }
sha2 = { workspace = true }
hotshot-task = { path = "../task" }
async-broadcast = { workspace = true }
chrono = "0.4"

[target.'cfg(all(async_executor_impl = "tokio"))'.dependencies]
tokio = { workspace = true }
Expand Down
5 changes: 5 additions & 0 deletions task-impls/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ use hotshot_types::{
use tracing::warn;

use crate::vote::HandleVoteEvent;
use chrono::Utc;
use snafu::Snafu;
use std::{
collections::{BTreeMap, HashSet},
Expand Down Expand Up @@ -815,6 +816,10 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, A: ConsensusApi<TYPES, I> +
.await;
self.vid_shares = self.vid_shares.split_off(&new_anchor_view);
consensus.last_decided_view = new_anchor_view;
consensus
.metrics
.last_decided_time
.set(Utc::now().timestamp().try_into().unwrap());
consensus.metrics.invalid_qc.set(0);
consensus
.metrics
Expand Down
3 changes: 3 additions & 0 deletions types/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ pub struct ConsensusMetricsValue {
pub last_synced_block_height: Box<dyn Gauge>,
/// The number of last decided view
pub last_decided_view: Box<dyn Gauge>,
/// Number of timestamp for the last decided time
pub last_decided_time: Box<dyn Gauge>,
/// The current view
pub current_view: Box<dyn Gauge>,
/// Number of views that are in-flight since the last decided view
Expand Down Expand Up @@ -210,6 +212,7 @@ impl ConsensusMetricsValue {
last_synced_block_height: metrics
.create_gauge(String::from("last_synced_block_height"), None),
last_decided_view: metrics.create_gauge(String::from("last_decided_view"), None),
last_decided_time: metrics.create_gauge(String::from("last_decided_time"), None),
current_view: metrics.create_gauge(String::from("current_view"), None),
number_of_views_since_last_decide: metrics
.create_gauge(String::from("number_of_views_since_last_decide"), None),
Expand Down

0 comments on commit 6f02c0d

Please sign in to comment.