Add structured JSON logging, OTel business metrics, and Grafana dashboard

Structured logging via JsonFormatter replaces uvicorn's default format so
Loki can parse timestamps and fields.  14 business metrics (scrape stats,
throttle events, circuit breaker state, cache hit rate, OCR success rate,
Celery task lifecycle) are defined in a shared metrics module and
instrumented across the scraper pipeline, API, and workers.  Celery
workers expose a Prometheus HTTP endpoint on configurable ports.
This commit is contained in:
Viktor Barzin 2026-02-14 10:59:12 +00:00
parent a1829957c1
commit d6edb747d2
No known key found for this signature in database
GPG key ID: 0EB088298288D958
12 changed files with 742 additions and 49 deletions

View file

@ -51,6 +51,7 @@ services:
- app_venv:/app/.venv
environment:
- ENV=dev
- SERVICE_NAME=api
- DB_CONNECTION_STRING=mysql+mysqldb://wrongmove:wrongmove@mysql:3306/wrongmove
- CELERY_BROKER_URL=redis://redis:6379/0
- CELERY_RESULT_BACKEND=redis://redis:6379/0
@ -74,11 +75,15 @@ services:
context: .
dockerfile: Dockerfile
container_name: rec-celery
ports:
- "9090:9090"
volumes:
- .:/app
- app_venv:/app/.venv
environment:
- ENV=dev
- SERVICE_NAME=celery-worker
- CELERY_METRICS_PORT=9090
- DB_CONNECTION_STRING=mysql+mysqldb://wrongmove:wrongmove@mysql:3306/wrongmove
- CELERY_BROKER_URL=redis://redis:6379/0
- CELERY_RESULT_BACKEND=redis://redis:6379/0
@ -98,11 +103,15 @@ services:
context: .
dockerfile: Dockerfile
container_name: rec-celery-beat
ports:
- "9091:9091"
volumes:
- .:/app
- app_venv:/app/.venv
environment:
- ENV=dev
- SERVICE_NAME=celery-beat
- CELERY_METRICS_PORT=9091
- DB_CONNECTION_STRING=mysql+mysqldb://wrongmove:wrongmove@mysql:3306/wrongmove
- CELERY_BROKER_URL=redis://redis:6379/0
- CELERY_RESULT_BACKEND=redis://redis:6379/0