Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: log if metrics_endpoint but no feature flag #5279

Merged
merged 10 commits into from
Nov 14, 2024
5 changes: 1 addition & 4 deletions stacks-signer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,7 @@ impl<S: Signer<T> + Send + 'static, T: SignerEventTrait + 'static> SpawnedSigner
);
let (res_send, res_recv) = channel();
let ev = SignerEventReceiver::new(config.network.is_mainnet());
#[cfg(feature = "monitoring_prom")]
{
crate::monitoring::start_serving_monitoring_metrics(config.clone()).ok();
}
crate::monitoring::start_serving_monitoring_metrics(config.clone()).ok();
let runloop = RunLoop::new(config.clone());
let mut signer: RunLoopSigner<S, T> = libsigner::Signer::new(runloop, ev, res_send);
let running_signer = signer.spawn(endpoint).expect("Failed to spawn signer");
Expand Down
6 changes: 3 additions & 3 deletions stacks-signer/src/monitoring/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ use ::prometheus::HistogramTimer;
#[cfg(feature = "monitoring_prom")]
use slog::slog_error;
#[cfg(not(feature = "monitoring_prom"))]
use slog::slog_warn;
use slog::slog_info;
#[cfg(feature = "monitoring_prom")]
use stacks_common::error;
#[cfg(not(feature = "monitoring_prom"))]
use stacks_common::warn;
use stacks_common::info;

use crate::config::GlobalConfig;

Expand Down Expand Up @@ -144,7 +144,7 @@ pub fn start_serving_monitoring_metrics(config: GlobalConfig) -> Result<(), Stri
#[cfg(not(feature = "monitoring_prom"))]
{
if config.metrics_endpoint.is_some() {
warn!("Not starting monitoring metrics server as the monitoring_prom feature is not enabled");
info!("`metrics_endpoint` is configured for the signer, but the monitoring_prom feature is not enabled. Not starting monitoring metrics server.");
}
}
Ok(())
Expand Down
96 changes: 38 additions & 58 deletions testnet/stacks-node/src/tests/nakamoto_integrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1500,19 +1500,16 @@ fn simple_neon_integration() {
// query for prometheus metrics
#[cfg(feature = "monitoring_prom")]
{
wait_for(10, || {
hstove marked this conversation as resolved.
Show resolved Hide resolved
let prom_http_origin = format!("http://{}", prom_bind);
let client = reqwest::blocking::Client::new();
let res = client
.get(&prom_http_origin)
.send()
.unwrap()
.text()
.unwrap();
let expected_result = format!("stacks_node_stacks_tip_height {block_height_pre_3_0}");
Ok(res.contains(&expected_result))
})
.expect("Prometheus metrics did not update");
let prom_http_origin = format!("http://{}", prom_bind);
let client = reqwest::blocking::Client::new();
let res = client
.get(&prom_http_origin)
.send()
.unwrap()
.text()
.unwrap();
let expected_result = format!("stacks_node_stacks_tip_height {block_height_pre_3_0}");
assert!(res.contains(&expected_result));
}

info!("Nakamoto miner started...");
Expand Down Expand Up @@ -1624,27 +1621,16 @@ fn simple_neon_integration() {
// make sure prometheus returns an updated number of processed blocks
#[cfg(feature = "monitoring_prom")]
{
wait_for(10, || {
let prom_http_origin = format!("http://{}", prom_bind);
let client = reqwest::blocking::Client::new();
let res = client
.get(&prom_http_origin)
.send()
.unwrap()
.text()
.unwrap();
let expected_result_1 = format!(
"stacks_node_stx_blocks_processed_total {}",
tip.stacks_block_height
);

let expected_result_2 = format!(
"stacks_node_stacks_tip_height {}",
tip.stacks_block_height - 1
);
Ok(res.contains(&expected_result_1) && res.contains(&expected_result_2))
})
.expect("Prometheus metrics did not update");
let prom_http_origin = format!("http://{}", prom_bind);
let client = reqwest::blocking::Client::new();
let res = client
.get(&prom_http_origin)
.send()
.unwrap()
.text()
.unwrap();
let expected_result = format!("stacks_node_stacks_tip_height {}", tip.stacks_block_height);
assert!(res.contains(&expected_result));
}

check_nakamoto_empty_block_heuristics();
Expand Down Expand Up @@ -6374,18 +6360,15 @@ fn signer_chainstate() {
.unwrap()
.stacks_block_height;
let prom_http_origin = format!("http://{}", prom_bind);
wait_for(10, || {
let client = reqwest::blocking::Client::new();
let res = client
.get(&prom_http_origin)
.send()
.unwrap()
.text()
.unwrap();
let expected_result = format!("stacks_node_stacks_tip_height {block_height_pre_3_0}");
Ok(res.contains(&expected_result))
})
.expect("Failed waiting for prometheus metrics to update")
let client = reqwest::blocking::Client::new();
let res = client
.get(&prom_http_origin)
.send()
.unwrap()
.text()
.unwrap();
let expected_result = format!("stacks_node_stacks_tip_height {block_height_pre_3_0}");
assert!(res.contains(&expected_result));
}

info!("Nakamoto miner started...");
Expand Down Expand Up @@ -6989,18 +6972,15 @@ fn continue_tenure_extend() {
#[cfg(feature = "monitoring_prom")]
{
let prom_http_origin = format!("http://{}", prom_bind);
wait_for(10, || {
let client = reqwest::blocking::Client::new();
let res = client
.get(&prom_http_origin)
.send()
.unwrap()
.text()
.unwrap();
let expected_result = format!("stacks_node_stacks_tip_height {block_height_pre_3_0}");
Ok(res.contains(&expected_result))
})
.expect("Prometheus metrics did not update");
let client = reqwest::blocking::Client::new();
let res = client
.get(&prom_http_origin)
.send()
.unwrap()
.text()
.unwrap();
let expected_result = format!("stacks_node_stacks_tip_height {block_height_pre_3_0}");
assert!(res.contains(&expected_result));
}

info!("Nakamoto miner started...");
Expand Down