diff --git a/src/cluster.rs b/src/cluster.rs index 255fc1ec52..6fe0f4ccd0 100644 --- a/src/cluster.rs +++ b/src/cluster.rs @@ -212,6 +212,9 @@ impl ClusterMap { pub fn merge(&self, map: Self) { for cluster in map.iter() { + let span = tracing::info_span!("applied_cluster", cluster = cluster.name,); + let _entered = span.enter(); + let cluster = cluster.value(); self.default_entry(cluster.name.clone()).merge(cluster); } diff --git a/src/config.rs b/src/config.rs index bd318013d9..b524703455 100644 --- a/src/config.rs +++ b/src/config.rs @@ -170,7 +170,6 @@ impl Config { tracing::trace!(resource=?response, "applying resource"); let apply_cluster = |cluster: Cluster| { - tracing::trace!(endpoints = %serde_json::to_value(&cluster).unwrap(), "applying new endpoints"); self.clusters .write() .default_entry(cluster.name.clone()) diff --git a/src/endpoint/locality.rs b/src/endpoint/locality.rs index 8009ec7f7c..e2bfb553ef 100644 --- a/src/endpoint/locality.rs +++ b/src/endpoint/locality.rs @@ -72,6 +72,22 @@ impl Locality { self } + pub fn colon_separated_string(&self) -> String { + let mut string = String::from(&*self.region); + + if !self.zone.is_empty() { + string += ":"; + string += &*self.zone; + } + + if !self.sub_zone.is_empty() { + string += ":"; + string += &*self.sub_zone; + } + + string + } + pub fn sub_zone(mut self, sub_zone: impl Into) -> Self { self.sub_zone = sub_zone.into(); self @@ -262,6 +278,31 @@ impl LocalitySet { pub fn merge(&mut self, cluster: &Self) { for (key, value) in &cluster.0 { + if tracing::enabled!(tracing::Level::INFO) { + let span = tracing::info_span!( + "applied_locality", + locality = &*key + .as_ref() + .map(|locality| locality.colon_separated_string()) + .unwrap_or_else(|| String::from("")) + ); + + let _entered = span.enter(); + if value.endpoints.is_empty() { + tracing::info!("removing all endpoints"); + } else if let Some(original_endpoints) = self.0.get(key) { + for endpoint in &original_endpoints.endpoints { + if !value.endpoints.contains(endpoint) { + tracing::info!(%endpoint.address, ?endpoint.metadata.known.tokens, "removing endpoint"); + } + } + } + + for endpoint in &value.endpoints { + tracing::info!(%endpoint.address, ?endpoint.metadata.known.tokens, "applying endpoint"); + } + } + let entry = self.0.entry(key.clone()).or_default(); *entry = value.clone(); }