refactor(metrics): unify per-provider AI metrics under provider-labeled counters and histograms

Aperta
#511 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Refactoring
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python
Ambito
ai, observability

Direzione di ricerca

Start in supernote/server/metrics.py, where the per-vendor Gemini and OpenAI counters and histograms are defined, then compare the _track_api_call helpers in each provider's backend.py. Check how OcrModel, SummaryModel and EmbeddingModel wrap calls, since the shared instrumentation probably belongs there. Done means ocr, summary and embedding calls emit provider-labeled request count and latency metrics, and tests/server/test_metrics.py passes. The design of the label scheme and the deprecation path needs maintainer input before coding.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

agent-ready ai p1 tech-debt

Summary

Each AI backend currently defines its own vendor-specific Prometheus metric families in supernote/server/metrics.py (supernote_gemini_api_calls_total, supernote_openai_api_calls_total, and matching *_duration_seconds histograms) and duplicates _track_api_call instrumentation logic inside each provider's backend.py.

As additional model providers are added (e.g. Mistral #304, named provider entries #476, and local/OS model backends), multiplying per-vendor metric names makes Prometheus queries, dashboards, and alerting brittle and forces boilerplate instrumentation into every new provider implementation.

Goals

  • Introduce unified provider-neutral AI metrics in supernote/server/metrics.py (e.g. supernote_ai_requests_total and supernote_ai_request_duration_seconds labeled by provider, capability/operation, and status).
  • Centralize request timing, error counting, and AIError logging in a shared helper or at the base capability wrapper layer (OcrModel, SummaryModel, EmbeddingModel) so every provider gets consistent observability out of the box.
  • Remove (or deprecate) bespoke per-vendor metric families and update tests/server/test_metrics.py and backend tests.

Acceptance Criteria

  • All AI model invocations (ocr, summary, embedding) emit unified Prometheus request count and latency metrics labeled with provider and capability/operation.
  • Adding a new AI provider no longer requires defining new Counter/Histogram objects in supernote/server/metrics.py.
Lingua principale
Python
Stelle
82
Fork
31
Merge medio
4h 55m
PR unite (30g)
168

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di allenporter/supernote

Tutte le issue di allenporter/supernote

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.