feat(observability): structured logging, metrics wiring, graceful degradation
- Item 5: Convert remaining printf-style logger call to structured logging (key=value format) in x402_middleware.py - Item 6: Wire CACHE_HITS counter into cache get() and per-tier SCRAPE_LATENCY histogram into UltimateScraper scrape loop - Item 7: Add circuit-breaker checks in extractor.py (Ollama) and routers/vision.py (OpenRouter) to fail fast and record success/failure when external services are down; attach recovery results to resilience registry for per-service circuit state 560 tests passing, ruff clean
This commit is contained in:
parent
2970c15dbb
commit
5a21133b1d
5 changed files with 20 additions and 1 deletions
4
cache.py
4
cache.py
|
|
@ -12,6 +12,8 @@ import json
|
|||
import time
|
||||
from collections import OrderedDict
|
||||
|
||||
from observability import CACHE_HITS
|
||||
|
||||
|
||||
class ResponseCache:
|
||||
"""Two-tier cache: local LRU + optional Redis persistence.
|
||||
|
|
@ -44,6 +46,8 @@ class ResponseCache:
|
|||
if entry["expires"] > now:
|
||||
self._hits += 1
|
||||
self._cache.move_to_end(key)
|
||||
if CACHE_HITS:
|
||||
CACHE_HITS.labels(cache_type="local").inc()
|
||||
return entry["data"]
|
||||
else:
|
||||
del self._cache[key]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue