Tiny add smg_manual_policy_cache_entries metric (#15987)

This commit is contained in:
fzyzcjy
2025-12-28 14:07:07 +08:00
committed by GitHub
parent 0294844f04
commit 325a4c1945
2 changed files with 10 additions and 0 deletions

View File

@@ -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!(

View File

@@ -161,6 +161,7 @@ impl LoadBalancingPolicy for ManualPolicy {
fn select_worker(&self, workers: &[Arc<dyn Worker>], info: &SelectWorkerInfo) -> Option<usize> {
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
}