Introduce an admin portal (React + Nginx), WebSocket routing, and API versioning middleware with `/api/v1/` prefix deprecation. Add master API key authentication, new Prometheus metrics for AI token consumption and active WebSockets, and extend S3 config with a public endpoint URL. Update test paths and fixtures to align with the new routing structure.
77 lines
2.6 KiB
Python
77 lines
2.6 KiB
Python
"""
|
|
Métriques Prometheus custom pour le hub d'images.
|
|
|
|
Exposed via /metrics par prometheus-fastapi-instrumentator.
|
|
"""
|
|
from prometheus_client import Counter, Histogram, Gauge
|
|
|
|
# ── Images ────────────────────────────────────────────────────
|
|
hub_images_uploaded = Counter(
|
|
"hub_images_uploaded_total",
|
|
"Nombre total d'images uploadées",
|
|
["client_id"],
|
|
)
|
|
|
|
hub_images_deleted = Counter(
|
|
"hub_images_deleted_total",
|
|
"Nombre total d'images supprimées",
|
|
["client_id"],
|
|
)
|
|
|
|
# ── AI ────────────────────────────────────────────────────────
|
|
hub_ai_tokens_consumed = Counter(
|
|
"hub_ai_tokens_consumed_total",
|
|
"Nombre total de tokens consommés",
|
|
["client_id", "model"],
|
|
)
|
|
|
|
# ── Pipeline ──────────────────────────────────────────────────
|
|
hub_pipeline_duration = Histogram(
|
|
"hub_pipeline_duration_seconds",
|
|
"Durée du pipeline de traitement complet",
|
|
buckets=[1, 5, 10, 30, 60, 120, 300],
|
|
)
|
|
|
|
hub_pipeline_step_duration = Histogram(
|
|
"hub_pipeline_step_duration_seconds",
|
|
"Durée de chaque étape du pipeline",
|
|
["step"],
|
|
buckets=[0.1, 0.5, 1, 5, 10, 30, 60],
|
|
)
|
|
|
|
hub_pipeline_errors = Counter(
|
|
"hub_pipeline_errors_total",
|
|
"Nombre d'erreurs pipeline",
|
|
["step"],
|
|
)
|
|
|
|
# ── Storage ───────────────────────────────────────────────────
|
|
hub_storage_used_bytes = Gauge(
|
|
"hub_storage_used_bytes",
|
|
"Espace de stockage utilisé par client",
|
|
["client_id"],
|
|
)
|
|
|
|
# ── WebSockets ────────────────────────────────────────────────
|
|
hub_active_websockets = Gauge(
|
|
"hub_active_websockets",
|
|
"Nombre de connexions WebSocket actives",
|
|
)
|
|
|
|
# ── ARQ ───────────────────────────────────────────────────────
|
|
hub_arq_jobs_enqueued = Counter(
|
|
"hub_arq_jobs_enqueued_total",
|
|
"Nombre de jobs ARQ enfilés",
|
|
["queue"],
|
|
)
|
|
|
|
hub_arq_jobs_completed = Counter(
|
|
"hub_arq_jobs_completed_total",
|
|
"Nombre de jobs ARQ terminés",
|
|
)
|
|
|
|
hub_arq_jobs_failed = Counter(
|
|
"hub_arq_jobs_failed_total",
|
|
"Nombre de jobs ARQ échoués",
|
|
)
|