Skip to content
This repository has been archived by the owner on Dec 26, 2024. It is now read-only.

Commit

Permalink
feat(consensus): add metrics to consensus (#2204)
Browse files Browse the repository at this point in the history
  • Loading branch information
asmaastarkware authored Jul 9, 2024
1 parent 39ea5c7 commit bcef46c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions crates/papyrus_common/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ pub const PAPYRUS_NUM_ACTIVE_OUTBOUND_SESSIONS: &str = "papyrus_num_active_outbo
// running. e.g via a monitoring endpoint.
/// Global variable set by the main config to enable collecting profiling metrics.
pub static COLLECT_PROFILING_METRICS: OnceLock<bool> = OnceLock::new();

/// The height most recently decided by consensus.
pub const PAPYRUS_CONSENSUS_HEIGHT: &str = "papyrus_consensus_height";
2 changes: 2 additions & 0 deletions crates/sequencing/papyrus_consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ description = "Reach consensus for Starknet"
[dependencies]
async-trait.workspace = true
futures.workspace = true
metrics.workspace = true
papyrus_common = { path = "../../papyrus_common", version = "0.4.0-dev.2" }
papyrus_network = { path = "../../papyrus_network", version = "0.4.0-dev.2" }
papyrus_config = { path = "../../papyrus_config", version = "0.4.0-dev.2" }
papyrus_protobuf = { path = "../../papyrus_protobuf", version = "0.4.0-dev.2" }
Expand Down
2 changes: 2 additions & 0 deletions crates/sequencing/papyrus_consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use std::sync::Arc;

use futures::channel::{mpsc, oneshot};
use papyrus_common::metrics as papyrus_metrics;
use papyrus_network::network_manager::SubscriberReceiver;
use papyrus_protobuf::consensus::{ConsensusMessage, Proposal};
use single_height_consensus::SingleHeightConsensus;
Expand Down Expand Up @@ -119,6 +120,7 @@ where
"Finished consensus for height: {current_height}. Agreed on block with id: {:x}",
block.id().0
);
metrics::gauge!(papyrus_metrics::PAPYRUS_CONSENSUS_HEIGHT, current_height.0 as f64);
current_height = current_height.unchecked_next();
}
}
Expand Down

0 comments on commit bcef46c

Please sign in to comment.