From 54df514bac6751a5305fd1ac3b7da7efe83e48f2 Mon Sep 17 00:00:00 2001 From: fzyzcjy <5236035+fzyzcjy@users.noreply.github.com> Date: Sun, 14 Dec 2025 13:57:20 +0800 Subject: [PATCH] Avoid confusing zero value metric when worker is removed (#15096) --- sgl-model-gateway/src/observability/metrics.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sgl-model-gateway/src/observability/metrics.rs b/sgl-model-gateway/src/observability/metrics.rs index 38ee5f709..c6d0d011c 100644 --- a/sgl-model-gateway/src/observability/metrics.rs +++ b/sgl-model-gateway/src/observability/metrics.rs @@ -502,12 +502,15 @@ impl RouterMetrics { // TODO delete the metrics (instead of setting them to zero) pub fn remove_worker_metrics(worker_url: &str) { - gauge!("sgl_router_cb_state","worker" => worker_url.to_string()).set(0.0); gauge!("sgl_router_cb_consecutive_failures","worker" => worker_url.to_string()).set(0.0); gauge!("sgl_router_cb_consecutive_successes","worker" => worker_url.to_string()).set(0.0); - gauge!("sgl_router_worker_health","worker" => worker_url.to_string()).set(0.0); gauge!("sgl_router_running_requests","worker" => worker_url.to_string()).set(0.0); gauge!("sgl_router_tree_size","worker" => worker_url.to_string()).set(0.0); + + // Zero for these metrics have special valid meaning, thus we set to -1 temporarily + // (and will remove them completely after https://github.com/metrics-rs/metrics/issues/653) + gauge!("sgl_router_cb_state","worker" => worker_url.to_string()).set(-1.0); + gauge!("sgl_router_worker_health","worker" => worker_url.to_string()).set(-1.0); } pub fn set_job_queue_depth(depth: usize) {