From a7c0002b08de09096af08a4fa46454dc08d02146 Mon Sep 17 00:00:00 2001 From: Greg Coppola Date: Fri, 28 Jan 2022 03:26:14 +0000 Subject: [PATCH 01/13] add hooks for promulgating "read" --- src/chainstate/stacks/db/blocks.rs | 3 +++ src/monitoring/mod.rs | 6 ++++++ src/monitoring/prometheus.rs | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/src/chainstate/stacks/db/blocks.rs b/src/chainstate/stacks/db/blocks.rs index 5cd82f8cb6..6c3822096c 100644 --- a/src/chainstate/stacks/db/blocks.rs +++ b/src/chainstate/stacks/db/blocks.rs @@ -82,6 +82,7 @@ use crate::types::chainstate::{ StacksAddress, StacksBlockHeader, StacksBlockId, StacksMicroblockHeader, }; use crate::{types, util}; +use monitoring::set_last_execution_cost_observed; use types::chainstate::BurnchainHeaderHash; #[derive(Debug, Clone, PartialEq)] @@ -5240,6 +5241,8 @@ impl StacksChainState { chainstate_tx.log_transactions_processed(&new_tip.index_block_hash(), &tx_receipts); + set_last_execution_cost_observed(&block_execution_cost); + let epoch_receipt = StacksEpochReceipt { header: new_tip, tx_receipts, diff --git a/src/monitoring/mod.rs b/src/monitoring/mod.rs index bc38e98fde..35008be8eb 100644 --- a/src/monitoring/mod.rs +++ b/src/monitoring/mod.rs @@ -34,6 +34,7 @@ use std::sync::Mutex; use util::db::sqlite_open; use util::db::Error as DatabaseError; use util::uint::{Uint256, Uint512}; +use vm::costs::ExecutionCost; #[cfg(feature = "monitoring_prom")] mod prometheus; @@ -104,6 +105,11 @@ pub fn increment_btc_blocks_received_counter() { prometheus::BTC_BLOCKS_RECEIVED_COUNTER.inc(); } +pub fn set_last_execution_cost_observed(execution_cost: &ExecutionCost) { + #[cfg(feature = "monitoring_prom")] + prometheus::LAST_EXECUTION_READ_COUNT.set(execution_cost.read_count); +} + pub fn increment_btc_ops_sent_counter() { #[cfg(feature = "monitoring_prom")] prometheus::BTC_OPS_SENT_COUNTER.inc(); diff --git a/src/monitoring/prometheus.rs b/src/monitoring/prometheus.rs index 0154e8ff55..33d96e5310 100644 --- a/src/monitoring/prometheus.rs +++ b/src/monitoring/prometheus.rs @@ -91,6 +91,11 @@ lazy_static! { "Total number of error logs emitted by node" )).unwrap(); + pub static ref LAST_EXECUTION_READ_COUNT: IntGauge = register_int_gauge!(opts!( + "execution_cost_runtime", + "`execution_cost_runtime` for the last block observed." + )).unwrap(); + pub static ref ACTIVE_MINERS_COUNT_GAUGE: IntGauge = register_int_gauge!(opts!( "stacks_node_active_miners_total", "Total number of active miners" From 3b9a8052489f7e444fceefa73a507c46e5de5c0b Mon Sep 17 00:00:00 2001 From: Greg Coppola Date: Fri, 28 Jan 2022 03:33:00 +0000 Subject: [PATCH 02/13] added other components to the cost --- src/monitoring/mod.rs | 9 +++++++++ src/monitoring/prometheus.rs | 20 ++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/monitoring/mod.rs b/src/monitoring/mod.rs index 35008be8eb..9a97737a5f 100644 --- a/src/monitoring/mod.rs +++ b/src/monitoring/mod.rs @@ -105,9 +105,18 @@ pub fn increment_btc_blocks_received_counter() { prometheus::BTC_BLOCKS_RECEIVED_COUNTER.inc(); } +#[allow(unused_variables)] pub fn set_last_execution_cost_observed(execution_cost: &ExecutionCost) { #[cfg(feature = "monitoring_prom")] prometheus::LAST_EXECUTION_READ_COUNT.set(execution_cost.read_count); + #[cfg(feature = "monitoring_prom")] + prometheus::LAST_EXECUTION_WRITE_COUNT.set(execution_cost.write_count); + #[cfg(feature = "monitoring_prom")] + prometheus::LAST_EXECUTION_READ_LENGTH.set(execution_cost.read_length); + #[cfg(feature = "monitoring_prom")] + prometheus::LAST_EXECUTION_WRITE_LENGTH.set(execution_cost.write_length); + #[cfg(feature = "monitoring_prom")] + prometheus::LAST_EXECUTION_RUNTIME.set(execution_cost.runtime); } pub fn increment_btc_ops_sent_counter() { diff --git a/src/monitoring/prometheus.rs b/src/monitoring/prometheus.rs index 33d96e5310..d05c2a7c3d 100644 --- a/src/monitoring/prometheus.rs +++ b/src/monitoring/prometheus.rs @@ -92,6 +92,26 @@ lazy_static! { )).unwrap(); pub static ref LAST_EXECUTION_READ_COUNT: IntGauge = register_int_gauge!(opts!( + "execution_cost_read_count", + "`execution_cost_read_count` for the last block observed." + )).unwrap(); + + pub static ref LAST_EXECUTION_WRITE_COUNT: IntGauge = register_int_gauge!(opts!( + "execution_cost_write_count", + "`execution_cost_write_count` for the last block observed." + )).unwrap(); + + pub static ref LAST_EXECUTION_READ_LENGTH: IntGauge = register_int_gauge!(opts!( + "execution_cost_read_length", + "`execution_cost_read_length` for the last block observed." + )).unwrap(); + + pub static ref LAST_EXECUTION_WRITE_LENGTH: IntGauge = register_int_gauge!(opts!( + "execution_cost_write_length", + "`execution_cost_write_length` for the last block observed." + )).unwrap(); + + pub static ref LAST_EXECUTION_RUNTIME: IntGauge = register_int_gauge!(opts!( "execution_cost_runtime", "`execution_cost_runtime` for the last block observed." )).unwrap(); From 01975a15d4f1c082f4c334adc9c8862e1d9d5752 Mon Sep 17 00:00:00 2001 From: Greg Coppola Date: Fri, 28 Jan 2022 14:25:13 +0000 Subject: [PATCH 03/13] try the conversion from u64 to i64 --- src/monitoring/mod.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/monitoring/mod.rs b/src/monitoring/mod.rs index 9a97737a5f..47b9c8f808 100644 --- a/src/monitoring/mod.rs +++ b/src/monitoring/mod.rs @@ -108,15 +108,15 @@ pub fn increment_btc_blocks_received_counter() { #[allow(unused_variables)] pub fn set_last_execution_cost_observed(execution_cost: &ExecutionCost) { #[cfg(feature = "monitoring_prom")] - prometheus::LAST_EXECUTION_READ_COUNT.set(execution_cost.read_count); + prometheus::LAST_EXECUTION_READ_COUNT.set(execution_cost.read_count.try_into().unwrap()); #[cfg(feature = "monitoring_prom")] - prometheus::LAST_EXECUTION_WRITE_COUNT.set(execution_cost.write_count); + prometheus::LAST_EXECUTION_WRITE_COUNT.set(execution_cost.write_count.try_into().unwrap()); #[cfg(feature = "monitoring_prom")] - prometheus::LAST_EXECUTION_READ_LENGTH.set(execution_cost.read_length); + prometheus::LAST_EXECUTION_READ_LENGTH.set(execution_cost.read_length.try_into().unwrap()); #[cfg(feature = "monitoring_prom")] - prometheus::LAST_EXECUTION_WRITE_LENGTH.set(execution_cost.write_length); + prometheus::LAST_EXECUTION_WRITE_LENGTH.set(execution_cost.write_length.try_into().unwrap()); #[cfg(feature = "monitoring_prom")] - prometheus::LAST_EXECUTION_RUNTIME.set(execution_cost.runtime); + prometheus::LAST_EXECUTION_RUNTIME.set(execution_cost.runtime.try_into().unwrap()); } pub fn increment_btc_ops_sent_counter() { From e3fca43c6a816b0f7a750105521c5e38fe5ea8a0 Mon Sep 17 00:00:00 2001 From: gregorycoppola Date: Fri, 28 Jan 2022 16:10:51 +0000 Subject: [PATCH 04/13] fix build with TryInto --- src/monitoring/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/monitoring/mod.rs b/src/monitoring/mod.rs index 47b9c8f808..174eb34804 100644 --- a/src/monitoring/mod.rs +++ b/src/monitoring/mod.rs @@ -35,6 +35,7 @@ use util::db::sqlite_open; use util::db::Error as DatabaseError; use util::uint::{Uint256, Uint512}; use vm::costs::ExecutionCost; +use std::convert::TryInto; #[cfg(feature = "monitoring_prom")] mod prometheus; From 6c41bfe7de25cf4a0b346fcce0ba5bba68a83c99 Mon Sep 17 00:00:00 2001 From: gregorycoppola Date: Fri, 28 Jan 2022 16:13:29 +0000 Subject: [PATCH 05/13] forgot to format --- src/monitoring/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/monitoring/mod.rs b/src/monitoring/mod.rs index 174eb34804..6f22c4e999 100644 --- a/src/monitoring/mod.rs +++ b/src/monitoring/mod.rs @@ -28,6 +28,7 @@ use crate::{ }, }; use burnchains::BurnchainSigner; +use std::convert::TryInto; use std::error::Error; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Mutex; @@ -35,7 +36,6 @@ use util::db::sqlite_open; use util::db::Error as DatabaseError; use util::uint::{Uint256, Uint512}; use vm::costs::ExecutionCost; -use std::convert::TryInto; #[cfg(feature = "monitoring_prom")] mod prometheus; From af311cc274bc77c5cfcf5debc5eeae59fb09acae Mon Sep 17 00:00:00 2001 From: gregorycoppola Date: Fri, 28 Jan 2022 16:19:14 +0000 Subject: [PATCH 06/13] changed the prometheus names --- src/monitoring/mod.rs | 10 +++++----- src/monitoring/prometheus.rs | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/monitoring/mod.rs b/src/monitoring/mod.rs index 6f22c4e999..8b73242768 100644 --- a/src/monitoring/mod.rs +++ b/src/monitoring/mod.rs @@ -109,15 +109,15 @@ pub fn increment_btc_blocks_received_counter() { #[allow(unused_variables)] pub fn set_last_execution_cost_observed(execution_cost: &ExecutionCost) { #[cfg(feature = "monitoring_prom")] - prometheus::LAST_EXECUTION_READ_COUNT.set(execution_cost.read_count.try_into().unwrap()); + prometheus::LAST_BLOCK_READ_COUNT.set(execution_cost.read_count.try_into().unwrap()); #[cfg(feature = "monitoring_prom")] - prometheus::LAST_EXECUTION_WRITE_COUNT.set(execution_cost.write_count.try_into().unwrap()); + prometheus::LAST_BLOCK_WRITE_COUNT.set(execution_cost.write_count.try_into().unwrap()); #[cfg(feature = "monitoring_prom")] - prometheus::LAST_EXECUTION_READ_LENGTH.set(execution_cost.read_length.try_into().unwrap()); + prometheus::LAST_BLOCK_READ_LENGTH.set(execution_cost.read_length.try_into().unwrap()); #[cfg(feature = "monitoring_prom")] - prometheus::LAST_EXECUTION_WRITE_LENGTH.set(execution_cost.write_length.try_into().unwrap()); + prometheus::LAST_BLOCK_WRITE_LENGTH.set(execution_cost.write_length.try_into().unwrap()); #[cfg(feature = "monitoring_prom")] - prometheus::LAST_EXECUTION_RUNTIME.set(execution_cost.runtime.try_into().unwrap()); + prometheus::LAST_BLOCK_RUNTIME.set(execution_cost.runtime.try_into().unwrap()); } pub fn increment_btc_ops_sent_counter() { diff --git a/src/monitoring/prometheus.rs b/src/monitoring/prometheus.rs index d05c2a7c3d..61e19b6825 100644 --- a/src/monitoring/prometheus.rs +++ b/src/monitoring/prometheus.rs @@ -91,27 +91,27 @@ lazy_static! { "Total number of error logs emitted by node" )).unwrap(); - pub static ref LAST_EXECUTION_READ_COUNT: IntGauge = register_int_gauge!(opts!( + pub static ref LAST_BLOCK_READ_COUNT: IntGauge = register_int_gauge!(opts!( "execution_cost_read_count", "`execution_cost_read_count` for the last block observed." )).unwrap(); - pub static ref LAST_EXECUTION_WRITE_COUNT: IntGauge = register_int_gauge!(opts!( + pub static ref LAST_BLOCK_WRITE_COUNT: IntGauge = register_int_gauge!(opts!( "execution_cost_write_count", "`execution_cost_write_count` for the last block observed." )).unwrap(); - pub static ref LAST_EXECUTION_READ_LENGTH: IntGauge = register_int_gauge!(opts!( + pub static ref LAST_BLOCK_READ_LENGTH: IntGauge = register_int_gauge!(opts!( "execution_cost_read_length", "`execution_cost_read_length` for the last block observed." )).unwrap(); - pub static ref LAST_EXECUTION_WRITE_LENGTH: IntGauge = register_int_gauge!(opts!( + pub static ref LAST_BLOCK_WRITE_LENGTH: IntGauge = register_int_gauge!(opts!( "execution_cost_write_length", "`execution_cost_write_length` for the last block observed." )).unwrap(); - pub static ref LAST_EXECUTION_RUNTIME: IntGauge = register_int_gauge!(opts!( + pub static ref LAST_BLOCK_RUNTIME: IntGauge = register_int_gauge!(opts!( "execution_cost_runtime", "`execution_cost_runtime` for the last block observed." )).unwrap(); From eaa4a3ad9b7338c4ded36bbc903e7a8cb0efbea4 Mon Sep 17 00:00:00 2001 From: gregorycoppola Date: Fri, 28 Jan 2022 17:07:19 +0000 Subject: [PATCH 07/13] saturate the limits --- src/monitoring/mod.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/monitoring/mod.rs b/src/monitoring/mod.rs index 8b73242768..11a0aaf70b 100644 --- a/src/monitoring/mod.rs +++ b/src/monitoring/mod.rs @@ -109,15 +109,15 @@ pub fn increment_btc_blocks_received_counter() { #[allow(unused_variables)] pub fn set_last_execution_cost_observed(execution_cost: &ExecutionCost) { #[cfg(feature = "monitoring_prom")] - prometheus::LAST_BLOCK_READ_COUNT.set(execution_cost.read_count.try_into().unwrap()); + prometheus::LAST_BLOCK_READ_COUNT.set(execution_cost.read_count.try_into().unwrap_or(i64::MAX)); #[cfg(feature = "monitoring_prom")] - prometheus::LAST_BLOCK_WRITE_COUNT.set(execution_cost.write_count.try_into().unwrap()); + prometheus::LAST_BLOCK_WRITE_COUNT.set(execution_cost.write_count.try_into().unwrap_or(i64::MAX)); #[cfg(feature = "monitoring_prom")] - prometheus::LAST_BLOCK_READ_LENGTH.set(execution_cost.read_length.try_into().unwrap()); + prometheus::LAST_BLOCK_READ_LENGTH.set(execution_cost.read_length.try_into().unwrap_or(i64::MAX)); #[cfg(feature = "monitoring_prom")] - prometheus::LAST_BLOCK_WRITE_LENGTH.set(execution_cost.write_length.try_into().unwrap()); + prometheus::LAST_BLOCK_WRITE_LENGTH.set(execution_cost.write_length.try_into().unwrap_or(i64::MAX)); #[cfg(feature = "monitoring_prom")] - prometheus::LAST_BLOCK_RUNTIME.set(execution_cost.runtime.try_into().unwrap()); + prometheus::LAST_BLOCK_RUNTIME.set(execution_cost.runtime.try_into().unwrap_or(i64::MAX)); } pub fn increment_btc_ops_sent_counter() { From b2700c442cc7af6ada2be2730707fb191b359e18 Mon Sep 17 00:00:00 2001 From: gregorycoppola Date: Fri, 28 Jan 2022 17:20:20 +0000 Subject: [PATCH 08/13] getting block limit into the prometheus thing --- src/chainstate/stacks/db/blocks.rs | 6 +++++- src/monitoring/mod.rs | 14 ++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/chainstate/stacks/db/blocks.rs b/src/chainstate/stacks/db/blocks.rs index 6c3822096c..d95b2b53f8 100644 --- a/src/chainstate/stacks/db/blocks.rs +++ b/src/chainstate/stacks/db/blocks.rs @@ -5003,6 +5003,10 @@ impl StacksChainState { None, )?; + let block_limit = clarity_tx + .block_limit() + .unwrap_or(ExecutionCost::max_value()); + let ( scheduled_miner_reward, block_execution_cost, @@ -5241,7 +5245,7 @@ impl StacksChainState { chainstate_tx.log_transactions_processed(&new_tip.index_block_hash(), &tx_receipts); - set_last_execution_cost_observed(&block_execution_cost); + set_last_execution_cost_observed(&block_execution_cost, &block_limit); let epoch_receipt = StacksEpochReceipt { header: new_tip, diff --git a/src/monitoring/mod.rs b/src/monitoring/mod.rs index 11a0aaf70b..54c0fa8d98 100644 --- a/src/monitoring/mod.rs +++ b/src/monitoring/mod.rs @@ -107,15 +107,21 @@ pub fn increment_btc_blocks_received_counter() { } #[allow(unused_variables)] -pub fn set_last_execution_cost_observed(execution_cost: &ExecutionCost) { +pub fn set_last_execution_cost_observed( + execution_cost: &ExecutionCost, + block_limit: &ExecutionCost, +) { #[cfg(feature = "monitoring_prom")] prometheus::LAST_BLOCK_READ_COUNT.set(execution_cost.read_count.try_into().unwrap_or(i64::MAX)); #[cfg(feature = "monitoring_prom")] - prometheus::LAST_BLOCK_WRITE_COUNT.set(execution_cost.write_count.try_into().unwrap_or(i64::MAX)); + prometheus::LAST_BLOCK_WRITE_COUNT + .set(execution_cost.write_count.try_into().unwrap_or(i64::MAX)); #[cfg(feature = "monitoring_prom")] - prometheus::LAST_BLOCK_READ_LENGTH.set(execution_cost.read_length.try_into().unwrap_or(i64::MAX)); + prometheus::LAST_BLOCK_READ_LENGTH + .set(execution_cost.read_length.try_into().unwrap_or(i64::MAX)); #[cfg(feature = "monitoring_prom")] - prometheus::LAST_BLOCK_WRITE_LENGTH.set(execution_cost.write_length.try_into().unwrap_or(i64::MAX)); + prometheus::LAST_BLOCK_WRITE_LENGTH + .set(execution_cost.write_length.try_into().unwrap_or(i64::MAX)); #[cfg(feature = "monitoring_prom")] prometheus::LAST_BLOCK_RUNTIME.set(execution_cost.runtime.try_into().unwrap_or(i64::MAX)); } From 4cf99f3788d860d23341d5e702b8367ad1f62cf0 Mon Sep 17 00:00:00 2001 From: gregorycoppola Date: Fri, 28 Jan 2022 17:27:22 +0000 Subject: [PATCH 09/13] use percentages --- src/monitoring/mod.rs | 12 +++++++----- src/monitoring/prometheus.rs | 10 +++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/monitoring/mod.rs b/src/monitoring/mod.rs index 54c0fa8d98..7256007fa9 100644 --- a/src/monitoring/mod.rs +++ b/src/monitoring/mod.rs @@ -106,24 +106,25 @@ pub fn increment_btc_blocks_received_counter() { prometheus::BTC_BLOCKS_RECEIVED_COUNTER.inc(); } +/// Log `execution_cost` as a ratio of `block_limit`. #[allow(unused_variables)] pub fn set_last_execution_cost_observed( execution_cost: &ExecutionCost, block_limit: &ExecutionCost, ) { #[cfg(feature = "monitoring_prom")] - prometheus::LAST_BLOCK_READ_COUNT.set(execution_cost.read_count.try_into().unwrap_or(i64::MAX)); + prometheus::LAST_BLOCK_READ_COUNT.set(execution_cost.read_count as f64 / block_limit.read_count as f64); #[cfg(feature = "monitoring_prom")] prometheus::LAST_BLOCK_WRITE_COUNT - .set(execution_cost.write_count.try_into().unwrap_or(i64::MAX)); + .set(execution_cost.write_count as f64 / block_limit.read_count as f64); #[cfg(feature = "monitoring_prom")] prometheus::LAST_BLOCK_READ_LENGTH - .set(execution_cost.read_length.try_into().unwrap_or(i64::MAX)); + .set(execution_cost.read_length as f64 / block_limit.read_length as f64); #[cfg(feature = "monitoring_prom")] prometheus::LAST_BLOCK_WRITE_LENGTH - .set(execution_cost.write_length.try_into().unwrap_or(i64::MAX)); + .set(execution_cost.write_length as f64 / block_limit.write_length as f64); #[cfg(feature = "monitoring_prom")] - prometheus::LAST_BLOCK_RUNTIME.set(execution_cost.runtime.try_into().unwrap_or(i64::MAX)); + prometheus::LAST_BLOCK_RUNTIME.set(execution_cost.runtime as f64 / block_limit.runtime as f64); } pub fn increment_btc_ops_sent_counter() { @@ -419,6 +420,7 @@ pub fn set_burnchain_signer(signer: BurnchainSigner) -> Result<(), SetGlobalBurn Ok(()) } +#[allow(unreachable_code)] pub fn get_burnchain_signer() -> Option { #[cfg(feature = "monitoring_prom")] { diff --git a/src/monitoring/prometheus.rs b/src/monitoring/prometheus.rs index 61e19b6825..96b5680e08 100644 --- a/src/monitoring/prometheus.rs +++ b/src/monitoring/prometheus.rs @@ -91,27 +91,27 @@ lazy_static! { "Total number of error logs emitted by node" )).unwrap(); - pub static ref LAST_BLOCK_READ_COUNT: IntGauge = register_int_gauge!(opts!( + pub static ref LAST_BLOCK_READ_COUNT: Gauge = register_gauge!(opts!( "execution_cost_read_count", "`execution_cost_read_count` for the last block observed." )).unwrap(); - pub static ref LAST_BLOCK_WRITE_COUNT: IntGauge = register_int_gauge!(opts!( + pub static ref LAST_BLOCK_WRITE_COUNT: Gauge = register_gauge!(opts!( "execution_cost_write_count", "`execution_cost_write_count` for the last block observed." )).unwrap(); - pub static ref LAST_BLOCK_READ_LENGTH: IntGauge = register_int_gauge!(opts!( + pub static ref LAST_BLOCK_READ_LENGTH: Gauge = register_gauge!(opts!( "execution_cost_read_length", "`execution_cost_read_length` for the last block observed." )).unwrap(); - pub static ref LAST_BLOCK_WRITE_LENGTH: IntGauge = register_int_gauge!(opts!( + pub static ref LAST_BLOCK_WRITE_LENGTH: Gauge = register_gauge!(opts!( "execution_cost_write_length", "`execution_cost_write_length` for the last block observed." )).unwrap(); - pub static ref LAST_BLOCK_RUNTIME: IntGauge = register_int_gauge!(opts!( + pub static ref LAST_BLOCK_RUNTIME: Gauge = register_gauge!(opts!( "execution_cost_runtime", "`execution_cost_runtime` for the last block observed." )).unwrap(); From 7fa6bcb4e9cd70ccf07a51a4f021344d327faa36 Mon Sep 17 00:00:00 2001 From: gregorycoppola Date: Mon, 31 Jan 2022 15:00:20 +0000 Subject: [PATCH 10/13] was failing fullness --- src/monitoring/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/monitoring/mod.rs b/src/monitoring/mod.rs index 7256007fa9..542636ddfd 100644 --- a/src/monitoring/mod.rs +++ b/src/monitoring/mod.rs @@ -113,7 +113,8 @@ pub fn set_last_execution_cost_observed( block_limit: &ExecutionCost, ) { #[cfg(feature = "monitoring_prom")] - prometheus::LAST_BLOCK_READ_COUNT.set(execution_cost.read_count as f64 / block_limit.read_count as f64); + prometheus::LAST_BLOCK_READ_COUNT + .set(execution_cost.read_count as f64 / block_limit.read_count as f64); #[cfg(feature = "monitoring_prom")] prometheus::LAST_BLOCK_WRITE_COUNT .set(execution_cost.write_count as f64 / block_limit.read_count as f64); From fde590187ae43900c1f53b5f79048481f649307c Mon Sep 17 00:00:00 2001 From: gregorycoppola Date: Mon, 31 Jan 2022 21:06:41 +0000 Subject: [PATCH 11/13] make prefix stacks_node_last_block_* --- src/monitoring/prometheus.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/monitoring/prometheus.rs b/src/monitoring/prometheus.rs index 96b5680e08..9a9d7f8f46 100644 --- a/src/monitoring/prometheus.rs +++ b/src/monitoring/prometheus.rs @@ -92,27 +92,27 @@ lazy_static! { )).unwrap(); pub static ref LAST_BLOCK_READ_COUNT: Gauge = register_gauge!(opts!( - "execution_cost_read_count", + "stacks_node_last_block_read_count", "`execution_cost_read_count` for the last block observed." )).unwrap(); pub static ref LAST_BLOCK_WRITE_COUNT: Gauge = register_gauge!(opts!( - "execution_cost_write_count", + "stacks_node_last_block_write_count", "`execution_cost_write_count` for the last block observed." )).unwrap(); pub static ref LAST_BLOCK_READ_LENGTH: Gauge = register_gauge!(opts!( - "execution_cost_read_length", + "stacks_node_last_block_read_length", "`execution_cost_read_length` for the last block observed." )).unwrap(); pub static ref LAST_BLOCK_WRITE_LENGTH: Gauge = register_gauge!(opts!( - "execution_cost_write_length", + "stacks_node_last_block_write_length", "`execution_cost_write_length` for the last block observed." )).unwrap(); pub static ref LAST_BLOCK_RUNTIME: Gauge = register_gauge!(opts!( - "execution_cost_runtime", + "stacks_node_last_block_runtime", "`execution_cost_runtime` for the last block observed." )).unwrap(); From ba45e6fab83fa54d884a6b12579c6918086b8454 Mon Sep 17 00:00:00 2001 From: Gregory Coppola <60008382+gregorycoppola@users.noreply.github.com> Date: Tue, 1 Feb 2022 12:34:28 -0500 Subject: [PATCH 12/13] kantai's suggestion for src/chainstate/stacks/db/blocks.rs Co-authored-by: pavitthrap --- src/chainstate/stacks/db/blocks.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/chainstate/stacks/db/blocks.rs b/src/chainstate/stacks/db/blocks.rs index d95b2b53f8..0407d3db74 100644 --- a/src/chainstate/stacks/db/blocks.rs +++ b/src/chainstate/stacks/db/blocks.rs @@ -5005,7 +5005,10 @@ impl StacksChainState { let block_limit = clarity_tx .block_limit() - .unwrap_or(ExecutionCost::max_value()); + .unwrap_or_else(|| { + warn!("Failed to read transaction block limit"); + ExecutionCost::max_value() + }); let ( scheduled_miner_reward, From b88d8ceb9a91fbdf856ebb5d5ff448e769fc2fe7 Mon Sep 17 00:00:00 2001 From: gregorycoppola Date: Tue, 1 Feb 2022 17:53:21 +0000 Subject: [PATCH 13/13] collapse the "check mempool feature" checks --- src/chainstate/stacks/db/blocks.rs | 10 ++++------ src/monitoring/mod.rs | 25 ++++++++++++------------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/chainstate/stacks/db/blocks.rs b/src/chainstate/stacks/db/blocks.rs index 7b99aeb9cf..0a45e14896 100644 --- a/src/chainstate/stacks/db/blocks.rs +++ b/src/chainstate/stacks/db/blocks.rs @@ -5009,12 +5009,10 @@ impl StacksChainState { None, )?; - let block_limit = clarity_tx - .block_limit() - .unwrap_or_else(|| { - warn!("Failed to read transaction block limit"); - ExecutionCost::max_value() - }); + let block_limit = clarity_tx.block_limit().unwrap_or_else(|| { + warn!("Failed to read transaction block limit"); + ExecutionCost::max_value() + }); let ( scheduled_miner_reward, diff --git a/src/monitoring/mod.rs b/src/monitoring/mod.rs index 542636ddfd..4d9f6fa49e 100644 --- a/src/monitoring/mod.rs +++ b/src/monitoring/mod.rs @@ -113,19 +113,18 @@ pub fn set_last_execution_cost_observed( block_limit: &ExecutionCost, ) { #[cfg(feature = "monitoring_prom")] - prometheus::LAST_BLOCK_READ_COUNT - .set(execution_cost.read_count as f64 / block_limit.read_count as f64); - #[cfg(feature = "monitoring_prom")] - prometheus::LAST_BLOCK_WRITE_COUNT - .set(execution_cost.write_count as f64 / block_limit.read_count as f64); - #[cfg(feature = "monitoring_prom")] - prometheus::LAST_BLOCK_READ_LENGTH - .set(execution_cost.read_length as f64 / block_limit.read_length as f64); - #[cfg(feature = "monitoring_prom")] - prometheus::LAST_BLOCK_WRITE_LENGTH - .set(execution_cost.write_length as f64 / block_limit.write_length as f64); - #[cfg(feature = "monitoring_prom")] - prometheus::LAST_BLOCK_RUNTIME.set(execution_cost.runtime as f64 / block_limit.runtime as f64); + { + prometheus::LAST_BLOCK_READ_COUNT + .set(execution_cost.read_count as f64 / block_limit.read_count as f64); + prometheus::LAST_BLOCK_WRITE_COUNT + .set(execution_cost.write_count as f64 / block_limit.read_count as f64); + prometheus::LAST_BLOCK_READ_LENGTH + .set(execution_cost.read_length as f64 / block_limit.read_length as f64); + prometheus::LAST_BLOCK_WRITE_LENGTH + .set(execution_cost.write_length as f64 / block_limit.write_length as f64); + prometheus::LAST_BLOCK_RUNTIME + .set(execution_cost.runtime as f64 / block_limit.runtime as f64); + } } pub fn increment_btc_ops_sent_counter() {