核心问题build_metric_definitions() 默认只在 store_threshold >= 2 时注册指标。 默认 store_threshold=0,导致 CPU cache 使用率在 Prometheus 上永远不可见。

  1. 声明 metrics 的名字 → CPUOffloadingMetrics 命名空间类
  2. build_metric_definitions() 关联名字、文字说明和类型(Gauge/Counter/Histogram) → CPU_CACHE_USAGE_PERC 始终注册,STORES_SKIPPED 条件注册
  3. get_stats() 实时计算并写入 OffloadingConnectorStats() → scheduler.aggregate() 合并 worker/manager stats → PrometheusStatLogger.observe() 写入 Gauge 对象

Takeaway:在现有 metrics infra 上挂新指标 = 声明名称 → 注册 metadata → get_stats() 实时计算 → 注册始终注册。