83d516afa1
FastAPI gateway with A/B/C lane orchestration, LiteLLM proxy config, Swarm stack (postgres, redis, VPN off-by-default), deploy/smoke/audit scripts.
32 lines
797 B
Python
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
|