Skip to content

Commit

Permalink
add current_time_thread && current_time_period (#4303)
Browse files Browse the repository at this point in the history
  • Loading branch information
modship authored Jul 31, 2023
1 parent 0cb927d commit 56b7cef
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
23 changes: 23 additions & 0 deletions massa-metrics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ pub struct MassaMetrics {
/// number of rolls
rolls: IntGauge,

// thread of actual slot
current_time_thread: IntGauge,
// period of actual slot
current_time_period: IntGauge,

/// number of elements in the active_history of execution
active_history: IntGauge,

Expand Down Expand Up @@ -206,6 +211,12 @@ impl MassaMetrics {
let stakers = IntGauge::new("stakers", "number of stakers").unwrap();
let rolls = IntGauge::new("rolls", "number of rolls").unwrap();

let current_time_period =
IntGauge::new("current_time_period", "period of actual slot").unwrap();

let current_time_thread =
IntGauge::new("current_time_thread", "thread of actual slot").unwrap();

let executed_final_slot =
IntCounter::new("executed_final_slot", "number of executed final slot").unwrap();
let executed_final_slot_with_block = IntCounter::new(
Expand Down Expand Up @@ -450,6 +461,8 @@ impl MassaMetrics {
let _ = prometheus::register(Box::new(protocol_tester_failed.clone()));
let _ = prometheus::register(Box::new(sc_messages_final.clone()));
let _ = prometheus::register(Box::new(async_message_pool_size.clone()));
let _ = prometheus::register(Box::new(current_time_period.clone()));
let _ = prometheus::register(Box::new(current_time_thread.clone()));

stopper = server::bind_metrics(addr);
}
Expand All @@ -462,6 +475,8 @@ impl MassaMetrics {
consensus_vec,
stakers,
rolls,
current_time_thread,
current_time_period,
active_history,
operations_pool,
endorsements_pool,
Expand Down Expand Up @@ -689,6 +704,14 @@ impl MassaMetrics {
self.process_available_processors.set(nb as i64);
}

pub fn set_current_time_period(&self, period: u64) {
self.current_time_period.set(period as i64);
}

pub fn set_current_time_thread(&self, thread: u8) {
self.current_time_thread.set(thread as i64);
}

/// Update the bandwidth metrics for all peers
/// HashMap<peer_id, (tx, rx)>
pub fn update_peers_tx_rx(&self, data: HashMap<String, (u64, u64)>) {
Expand Down
3 changes: 3 additions & 0 deletions massa-node/src/survey.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ impl MassaSurvey {
massa_metrics.set_stakers(staker_vec.len());
let rolls_count = staker_vec.iter().map(|(_, r)| *r).sum::<u64>();
massa_metrics.set_rolls(rolls_count as usize);
let current_slot = get_latest_block_slot_at_timestamp(config.0, config.1, config.2, now).unwrap_or(None).unwrap_or(Slot::new(0, 0));
massa_metrics.set_current_time_thread(current_slot.thread);
massa_metrics.set_current_time_period(current_slot.period);
}

{
Expand Down

0 comments on commit 56b7cef

Please sign in to comment.