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
|
|
@ -19,6 +19,7 @@ from typing import Any, ClassVar
|
|||
from urllib.parse import urlparse
|
||||
|
||||
from errors import InvalidRequestError
|
||||
from observability import SCRAPE_LATENCY
|
||||
from resilience import registry
|
||||
from url_guard import validate_url
|
||||
|
||||
|
|
@ -188,6 +189,8 @@ class UltimateScraper:
|
|||
registry.record_domain_tier_result(domain, tier_name, success, latency)
|
||||
if breaker_name:
|
||||
registry.record_service_result(breaker_name, success)
|
||||
if SCRAPE_LATENCY:
|
||||
SCRAPE_LATENCY.labels(method=tier_name).observe(latency)
|
||||
|
||||
if success:
|
||||
method = "premium_proxy" if tier_name == "premium_proxy" else tier_name
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue