Files
EventHubAiRouter/router/metrics.py
T
aleksey 83d516afa1
CI / build-gateway (push) Successful in 27s
CI / sync-config (push) Successful in 1s
feat(ift): EventHub AI Router stack for Zed
FastAPI gateway with A/B/C lane orchestration, LiteLLM proxy config,
Swarm stack (postgres, redis, VPN off-by-default), deploy/smoke/audit scripts.
2026-08-07 22:06:41 +03:00

32 lines
797 B
Python

"""Prometheus metrics for gateway tier/lane routing."""
from __future__ import annotations
from prometheus_client import CONTENT_TYPE_LATEST, Counter, Histogram, generate_latest
REQUESTS = Counter(
"ai_router_requests_total",
"Total routed requests",
["tier", "lane", "model", "status"],
)
ESCALATIONS = Counter(
"ai_router_escalations_total",
"Lane escalations",
["from_lane", "to_lane", "reason"],
)
CLASSIFY = Counter(
"ai_router_classify_total",
"Classification results",
["tier"],
)
DURATION = Histogram(
"ai_router_request_duration_seconds",
"Request duration",
["tier", "model"],
buckets=(0.1, 0.25, 0.5, 1, 2, 5, 10, 30, 60, 120, 180),
)
def metrics_payload() -> tuple[bytes, str]:
return generate_latest(), CONTENT_TYPE_LATEST