feat: детали проверки в тултипе сегментов uptime
Build and deploy / build-deploy (push) Has been cancelled

Сегмент при наведении показывает тултип: успех/провал, время
проверки, латентность и текст ошибки.

Бэкенд: в таблицу checks добавлена колонка error (миграция через
ALTER TABLE), probe.py и ручной /api/check теперь сохраняют текст
ошибки, /api/models отдаёт детали каждой проверки в history.
This commit is contained in:
2026-10-21 22:24:17 +00:00
parent 3f6b5768d0
commit 1fb770fc52
3 changed files with 122 additions and 19 deletions
+11 -9
View File
@@ -19,8 +19,9 @@ TIMEOUT = int(os.environ.get("CHECK_TIMEOUT", "30"))
CONCURRENCY = int(os.environ.get("CHECK_CONCURRENCY", "5"))
def check_model(model_id: str) -> tuple[bool, int | None]:
def check_model(model_id: str) -> tuple[bool, int | None, str | None]:
t0 = time.time()
error = None
try:
body = json.dumps({
"model": model_id,
@@ -40,10 +41,11 @@ def check_model(model_id: str) -> tuple[bool, int | None]:
content = resp["choices"][0]["message"]["content"]
ok = bool(content.strip())
except Exception as e:
print(f" ✗ {model_id}: {e}", file=sys.stderr)
error = f"{type(e).__name__}: {e}"
print(f" ✗ {model_id}: {error}", file=sys.stderr)
ok = False
latency = int((time.time() - t0) * 1000) if ok else None
return ok, latency
latency = int((time.time() - t0) * 1000)
return ok, latency, error
def run():
@@ -56,8 +58,8 @@ def run():
from concurrent.futures import ThreadPoolExecutor, as_completed
def do(mid):
ok, lat = check_model(mid)
return mid, ok, lat
ok, lat, err = check_model(mid)
return mid, ok, lat, err
db = sqlite3.connect(DB_PATH, check_same_thread=False)
now = datetime.now(timezone.utc).isoformat()
@@ -66,10 +68,10 @@ def run():
futs = {ex.submit(do, m): m for m in models}
done = ok_count = 0
for f in as_completed(futs):
mid, ok, lat = f.result()
mid, ok, lat, err = f.result()
db.execute(
"INSERT INTO checks (model_id, checked_at, ok, latency_ms) VALUES (?,?,?,?)",
(mid, now, int(ok), lat),
"INSERT INTO checks (model_id, checked_at, ok, latency_ms, error) VALUES (?,?,?,?,?)",
(mid, now, int(ok), lat, err),
)
done += 1
if ok: