diff options
author | Alex Auvolat <alex@adnab.me> | 2022-12-05 19:10:15 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-12-05 19:10:15 +0100 |
commit | ba5bf133f61c3a56728c2ab73e11abf47ef8348c (patch) | |
tree | 26854702b5669fc6d907467f5358f9f062044be0 /src/proxy_config.rs | |
parent | 5d38f2cf7f312de69a3106556fc43219ca1473c3 (diff) | |
download | tricot-ba5bf133f61c3a56728c2ab73e11abf47ef8348c.tar.gz tricot-ba5bf133f61c3a56728c2ab73e11abf47ef8348c.zip |
Add duration metric and improve others as well
Diffstat (limited to 'src/proxy_config.rs')
-rw-r--r-- | src/proxy_config.rs | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/proxy_config.rs b/src/proxy_config.rs index 24ade8b..2ce462e 100644 --- a/src/proxy_config.rs +++ b/src/proxy_config.rs @@ -189,7 +189,7 @@ fn parse_consul_catalog( let mut entries = vec![]; - for (service_name, svc) in catalog.services.iter() { + for (_, svc) in catalog.services.iter() { let ip_addr = match svc.address.parse() { Ok(ip) => ip, _ => match catalog.node.address.parse() { @@ -222,7 +222,7 @@ fn parse_consul_catalog( for tag in svc.tags.iter() { if let Some(ent) = parse_tricot_tag( - service_name.clone(), + svc.service.clone(), tag, addr, &add_headers[..], @@ -388,15 +388,22 @@ impl ProxyConfigMetrics { .u64_value_observer("proxy_config_entries", move |observer| { let mut patterns = HashMap::new(); for ent in rx.borrow().entries.iter() { - let pat = format!( - "{}{}", - ent.host, - ent.path_prefix.as_deref().unwrap_or_default() + let attrs = ( + ent.host.to_string(), + ent.path_prefix.clone().unwrap_or_default(), + ent.service_name.clone(), ); - *patterns.entry(pat).or_default() += 1; + *patterns.entry(attrs).or_default() += 1; } - for (pat, num) in patterns { - observer.observe(num, &[KeyValue::new("host", pat)]); + for ((host, prefix, svc), num) in patterns { + observer.observe( + num, + &[ + KeyValue::new("host", host), + KeyValue::new("path_prefix", prefix), + KeyValue::new("service", svc), + ], + ); } }) .with_description("Number of proxy entries (back-ends) configured in Tricot") |