Skip to content

Commit

Permalink
Bump prom_client to 0.23, fix a few build errors triggered by same (#…
Browse files Browse the repository at this point in the history
…1424)

* Bump prom_client to 0.23, fix a few build errors triggered by same

Signed-off-by: Benjamin Leggett <[email protected]>

* fuzz

Signed-off-by: Benjamin Leggett <[email protected]>

---------

Signed-off-by: Benjamin Leggett <[email protected]>
  • Loading branch information
bleggett authored Jan 13, 2025
1 parent a07261e commit e94f24f
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ log = "0.4"
nix = { version = "0.29", features = ["socket", "sched", "uio", "fs", "ioctl", "user", "net", "mount"] }
once_cell = "1.19"
ppp = "2.2"
prometheus-client = { version = "0.22" }
prometheus-client = { version = "0.23" }
prometheus-parse = "0.2"
prost = "0.13"
prost-types = "0.13"
Expand Down Expand Up @@ -101,7 +101,7 @@ flurry = "0.5"
h2 = "0.4"
http = "1.2"
split-iter = "0.1"
arcstr = { version = "1.1", features = ["serde"] }
arcstr = { version = "1.2", features = ["serde"] }
tracing-core = "0.1"
tracing-appender = "0.2"
tokio-util = { version = "0.7", features = ["io-util"] }
Expand Down
4 changes: 2 additions & 2 deletions fuzz/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions src/inpod/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,15 @@
// limitations under the License.

use prometheus_client::metrics::counter::Counter;
use prometheus_client::metrics::family::Family;
use prometheus_client::metrics::gauge::Gauge;
use prometheus_client::registry::Registry;

#[derive(Default)]
pub struct Metrics {
pub(super) active_proxy_count: Family<(), Gauge>,
pub(super) pending_proxy_count: Family<(), Gauge>,
pub(super) proxies_started: Family<(), Counter>,
pub(super) proxies_stopped: Family<(), Counter>,
pub(super) active_proxy_count: Gauge,
pub(super) pending_proxy_count: Gauge,
pub(super) proxies_started: Counter,
pub(super) proxies_stopped: Counter,
}

impl Metrics {
Expand Down
16 changes: 7 additions & 9 deletions src/inpod/statemanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,13 @@ impl WorkloadProxyManagerState {
let metrics = self.metrics.clone();
let admin_handler = self.admin_handler.clone();

metrics.proxies_started.get_or_create(&()).inc();
metrics.proxies_started.inc();
if let Some(proxy) = proxies.proxy {
tokio::spawn(
async move {
proxy.run().await;
debug!("proxy for workload {:?} exited", uid);
metrics.proxies_stopped.get_or_create(&()).inc();
metrics.proxies_stopped.inc();
admin_handler.proxy_down(&uid);
}
.instrument(tracing::info_span!("proxy", wl=%format!("{}/{}", workload_info.namespace, workload_info.name))),
Expand Down Expand Up @@ -378,11 +378,9 @@ impl WorkloadProxyManagerState {
fn update_proxy_count_metrics(&self) {
self.metrics
.active_proxy_count
.get_or_create(&())
.set(self.workload_states.len().try_into().unwrap_or(-1));
self.metrics
.pending_proxy_count
.get_or_create(&())
.set(self.pending_workloads.len().try_into().unwrap_or(-1));
}
}
Expand Down Expand Up @@ -501,7 +499,7 @@ mod tests {
state.retry_pending().await;
assert!(!state.have_pending());
state.drain().await;
assert_eq!(m.proxies_started.get_or_create(&()).get(), 1);
assert_eq!(m.proxies_started.get(), 1);
}

#[tokio::test]
Expand Down Expand Up @@ -541,7 +539,7 @@ mod tests {
state.retry_pending().await;
assert!(!state.have_pending());
state.drain().await;
assert_eq!(m.proxies_started.get_or_create(&()).get(), 1);
assert_eq!(m.proxies_started.get(), 1);
}

#[tokio::test]
Expand Down Expand Up @@ -678,7 +676,7 @@ mod tests {
.await
.unwrap();

assert_eq!(m.proxies_started.get_or_create(&()).get(), 1);
assert_eq!(m.proxies_started.get(), 1);

state.drain().await;
}
Expand Down Expand Up @@ -707,8 +705,8 @@ mod tests {
state.process_msg(add2).await.unwrap();
state.drain().await;

assert_eq!(m.proxies_started.get_or_create(&()).get(), 2);
assert_eq!(m.active_proxy_count.get_or_create(&()).get(), 1);
assert_eq!(m.proxies_started.get(), 2);
assert_eq!(m.active_proxy_count.get(), 1);
}

#[tokio::test]
Expand Down
6 changes: 3 additions & 3 deletions src/inpod/workloadmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ pub(crate) mod tests {
assert_end_stream(res);

assert_eq!(state.workload_states().len(), 0);
assert_eq!(m.active_proxy_count.get_or_create(&()).get(), 0);
assert_eq!(m.active_proxy_count.get(), 0);
assert!(readiness.ready.pending().is_empty());

state.drain().await;
Expand Down Expand Up @@ -608,7 +608,7 @@ pub(crate) mod tests {
.map(crate::inpod::WorkloadUid::from)
.collect();
assert_eq!(key_set, expected_key_set);
assert_eq!(m.active_proxy_count.get_or_create(&()).get(), 2);
assert_eq!(m.active_proxy_count.get(), 2);

// second connection - don't send the one of the proxies here, to see ztunnel reconciles and removes it:
let (s1, mut s2) = UnixStream::pair().unwrap();
Expand All @@ -631,7 +631,7 @@ pub(crate) mod tests {
// only second workload should remain
assert_eq!(state.workload_states().len(), 1);
assert_eq!(state.workload_states().keys().next(), Some(&uid(1)));
assert_eq!(m.active_proxy_count.get_or_create(&()).get(), 1);
assert_eq!(m.active_proxy_count.get(), 1);
assert!(readiness.ready.pending().is_empty());

state.drain().await;
Expand Down
5 changes: 4 additions & 1 deletion src/strng.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ pub struct RichStrng(Strng);

impl prometheus_client::encoding::EncodeLabelValue for RichStrng {
fn encode(&self, encoder: &mut LabelValueEncoder) -> Result<(), Error> {
prometheus_client::encoding::EncodeLabelValue::encode(&self.0.as_ref(), encoder)
prometheus_client::encoding::EncodeLabelValue::encode(
&<ArcStr as AsRef<str>>::as_ref(&self.0),
encoder,
)
}
}

Expand Down

0 comments on commit e94f24f

Please sign in to comment.