mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-09 03:31:45 +00:00
Configurable monitoring endpoint frequency (#3530)
## Issue Addressed Closes #3514 ## Proposed Changes - Change default monitoring endpoint frequency to 120 seconds to fit with 30k requests/month limit. - Allow configuration of the monitoring endpoint frequency using `--monitoring-endpoint-frequency N` where `N` is a value in seconds.
This commit is contained in:
@@ -16,7 +16,7 @@ use types::*;
|
||||
pub use types::ProcessType;
|
||||
|
||||
/// Duration after which we collect and send metrics to remote endpoint.
|
||||
pub const UPDATE_DURATION: u64 = 60;
|
||||
pub const DEFAULT_UPDATE_DURATION: u64 = 60;
|
||||
/// Timeout for HTTP requests.
|
||||
pub const TIMEOUT_DURATION: u64 = 5;
|
||||
|
||||
@@ -55,6 +55,8 @@ pub struct Config {
|
||||
/// Path for the cold database required for fetching beacon db size metrics.
|
||||
/// Note: not relevant for validator and system metrics.
|
||||
pub freezer_db_path: Option<PathBuf>,
|
||||
/// User-defined update period in seconds.
|
||||
pub update_period_secs: Option<u64>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
@@ -64,6 +66,7 @@ pub struct MonitoringHttpClient {
|
||||
db_path: Option<PathBuf>,
|
||||
/// Path to the freezer database.
|
||||
freezer_db_path: Option<PathBuf>,
|
||||
update_period: Duration,
|
||||
monitoring_endpoint: SensitiveUrl,
|
||||
log: slog::Logger,
|
||||
}
|
||||
@@ -74,6 +77,9 @@ impl MonitoringHttpClient {
|
||||
client: reqwest::Client::new(),
|
||||
db_path: config.db_path.clone(),
|
||||
freezer_db_path: config.freezer_db_path.clone(),
|
||||
update_period: Duration::from_secs(
|
||||
config.update_period_secs.unwrap_or(DEFAULT_UPDATE_DURATION),
|
||||
),
|
||||
monitoring_endpoint: SensitiveUrl::parse(&config.monitoring_endpoint)
|
||||
.map_err(|e| format!("Invalid monitoring endpoint: {:?}", e))?,
|
||||
log,
|
||||
@@ -100,10 +106,15 @@ impl MonitoringHttpClient {
|
||||
let mut interval = interval_at(
|
||||
// Have some initial delay for the metrics to get initialized
|
||||
Instant::now() + Duration::from_secs(25),
|
||||
Duration::from_secs(UPDATE_DURATION),
|
||||
self.update_period,
|
||||
);
|
||||
|
||||
info!(self.log, "Starting monitoring api"; "endpoint" => %self.monitoring_endpoint);
|
||||
info!(
|
||||
self.log,
|
||||
"Starting monitoring API";
|
||||
"endpoint" => %self.monitoring_endpoint,
|
||||
"update_period" => format!("{}s", self.update_period.as_secs()),
|
||||
);
|
||||
|
||||
let update_future = async move {
|
||||
loop {
|
||||
|
||||
Reference in New Issue
Block a user