fix(governance): skip non-finite slo values
This commit is contained in:
@@ -399,6 +399,7 @@ class GovernanceAgent:
|
||||
2026-04-27 P3.4 by Claude — AI SLO(ADR-100)
|
||||
"""
|
||||
import httpx
|
||||
import math
|
||||
|
||||
from src.core.config import settings
|
||||
|
||||
@@ -457,6 +458,21 @@ class GovernanceAgent:
|
||||
)
|
||||
continue
|
||||
value = float(result_list[0]["value"][1])
|
||||
if not math.isfinite(value):
|
||||
results[name] = {
|
||||
"name": name,
|
||||
"status": "skipped",
|
||||
"error": "non_finite_value",
|
||||
"reason": "prometheus_nan_or_inf",
|
||||
"hint": "SLO 分母目前沒有足夠事件,等待下一個有效樣本再評估",
|
||||
}
|
||||
logger.warning(
|
||||
"governance_slo_non_finite",
|
||||
slo=name,
|
||||
query=query,
|
||||
value=str(result_list[0]["value"][1]),
|
||||
)
|
||||
continue
|
||||
threshold = hard_red_lines[name]
|
||||
target = slo_targets[name]
|
||||
violated = value < threshold
|
||||
|
||||
Reference in New Issue
Block a user