feat(ocr): increment ocr_skipped_pages_total on per-page engine failure

Bumps the counter in both /ocr/stream except blocks (standard and guided
generators) so the existing skipped_pages local variable now also flows
into Prometheus.

Refs #652 (AC3b)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-05-21 16:06:50 +02:00
parent 79edb94558
commit 3fa3460dbf
2 changed files with 45 additions and 0 deletions

View File

@@ -219,6 +219,7 @@ async def run_ocr_stream(request: OcrRequest):
except Exception:
logger.exception("Guided OCR failed on page %d", page_idx)
skipped_pages += 1
metrics.ocr_skipped_pages_total.inc()
yield json.dumps({
"type": "error",
"pageNumber": page_idx,
@@ -274,6 +275,7 @@ async def run_ocr_stream(request: OcrRequest):
except Exception:
logger.exception("OCR failed on page %d", page_idx)
skipped_pages += 1
metrics.ocr_skipped_pages_total.inc()
yield json.dumps({
"type": "error",
"pageNumber": page_idx,