Imago/app/metrics.py
Bruno Charest cc99fea20a
Some checks failed
CI / Lint & Format (push) Has been cancelled
CI / Tests (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / Docker Build (push) Has been cancelled
Add comprehensive test suite for image processing and related services
- 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.
2026-02-24 11:22:10 -05:00

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",
)