feat: allow configuring ping bucket sizes
This commit is contained in:
parent
854ddced3a
commit
2972cb2476
1 changed files with 14 additions and 5 deletions
|
@ -45,6 +45,8 @@ pub(crate) struct PingConfig {
|
|||
#[serde_as(as = "DurationMilliSeconds<f64>")]
|
||||
#[serde(default = "default_timeout")]
|
||||
pub(crate) timeout: Duration,
|
||||
#[serde(default = "default_buckets")]
|
||||
pub(crate) bucket_sizes: Vec<f64>,
|
||||
pub(crate) hosts: HashMap<std::net::IpAddr, u64>,
|
||||
}
|
||||
|
||||
|
@ -52,6 +54,14 @@ fn default_timeout() -> Duration {
|
|||
Duration::from_secs(3)
|
||||
}
|
||||
|
||||
fn default_buckets() -> Vec<f64> {
|
||||
vec![
|
||||
0.5, 1.0, 5.0, 10.0, 15.0, 20.0, 25.0, 50.0, 75.0, 100.0, 150.0, 200.0, 250.0, 300.0,
|
||||
350.0, 400.0, 450.0, 500.0, 550.0, 600.0, 650.0, 700.0, 750.0, 800.0, 900.0, 1000.0,
|
||||
1250.0, 1500.0, 1750.0, 2000.0,
|
||||
]
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Clone)]
|
||||
pub(crate) struct LogConfig {
|
||||
pub(crate) level: log::LevelFilter,
|
||||
|
@ -117,11 +127,10 @@ pub(crate) fn setup_app() -> Result<App> {
|
|||
|
||||
pub(crate) fn setup_prometheus(config: &Config) -> Result<PrometheusHandle> {
|
||||
let handle = PrometheusBuilder::new()
|
||||
.set_buckets_for_metric(Matcher::Full("ping_rtt_milliseconds".into()), &vec![
|
||||
0.5, 1.0, 5.0, 10.0, 15.0, 20.0, 25.0, 50.0, 75.0, 100.0, 150.0, 200.0, 250.0, 300.0,
|
||||
350.0, 400.0, 450.0, 500.0, 550.0, 600.0, 650.0, 700.0, 750.0, 800.0, 900.0, 1000.0,
|
||||
1250.0, 1500.0, 1750.0, 2000.0,
|
||||
])?
|
||||
.set_buckets_for_metric(
|
||||
Matcher::Full("ping_rtt_milliseconds".into()),
|
||||
&config.ping.bucket_sizes,
|
||||
)?
|
||||
.install_recorder()?;
|
||||
|
||||
for target in config.ping.hosts.keys() {
|
||||
|
|
Loading…
Reference in a new issue