- Implement tests for database generator to ensure proper session handling. - Create tests for EXIF extraction and conversion functions. - Add tests for image-related endpoints, ensuring proper data retrieval and isolation between clients. - Develop tests for OCR functionality, including language detection and text extraction. - Introduce tests for the image processing pipeline, covering success and failure scenarios. - Validate rate limiting functionality and ensure independent counters for different clients. - Implement scraper tests to verify HTML content fetching and error handling. - Add unit tests for various services, including storage and filename generation. - Establish worker entry point for ARQ to handle background image processing tasks.
63 lines
2.0 KiB
Python
63 lines
2.0 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_plan"],
|
|
)
|
|
|
|
hub_images_deleted = Counter(
|
|
"hub_images_deleted_total",
|
|
"Nombre total d'images supprimées",
|
|
)
|
|
|
|
# ── 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"],
|
|
)
|
|
|
|
# ── 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",
|
|
)
|