diff --git a/sgl-model-gateway/src/observability/metrics.rs b/sgl-model-gateway/src/observability/metrics.rs index 5523f5c75..de380a864 100644 --- a/sgl-model-gateway/src/observability/metrics.rs +++ b/sgl-model-gateway/src/observability/metrics.rs @@ -190,6 +190,10 @@ pub fn init_metrics() { "smg_worker_errors_total", "Worker-level errors by worker_type, connection_mode, error_type" ); + describe_gauge!( + "smg_manual_policy_cache_entries", + "Number of routing entries in manual policy cache" + ); // Layer 3: Worker resilience metrics (circuit breaker) describe_gauge!( @@ -810,6 +814,11 @@ impl Metrics { .increment(1); } + /// Set manual policy cache entries count + pub fn set_manual_policy_cache_entries(count: usize) { + gauge!("smg_manual_policy_cache_entries").set(count as f64); + } + /// Record consistent hashing policy execution branch for routing decisions pub fn record_worker_consistent_hashing_policy_branch(branch: &'static str) { counter!( diff --git a/sgl-model-gateway/src/policies/manual.rs b/sgl-model-gateway/src/policies/manual.rs index f4d55828d..55d3c6cb2 100644 --- a/sgl-model-gateway/src/policies/manual.rs +++ b/sgl-model-gateway/src/policies/manual.rs @@ -161,6 +161,7 @@ impl LoadBalancingPolicy for ManualPolicy { fn select_worker(&self, workers: &[Arc], info: &SelectWorkerInfo) -> Option { let (result, branch) = self.select_worker_impl(workers, info); Metrics::record_worker_manual_policy_branch(branch.as_str()); + Metrics::set_manual_policy_cache_entries(self.routing_map.len()); result }