multi-agent-verifier / monitoring.py
vriddhi saini
Remove file logging to avoid missing directory error on HF Space
a17a837
raw
history blame contribute delete
935 Bytes
import logging
import time
from prometheus_client import Counter, Histogram, start_http_server
# Only use console logging (no file handler)
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(levelname)s - %(message)s',
handlers=[logging.StreamHandler()] # removed FileHandler
)
REQUEST_COUNT = Counter('gradio_requests_total', 'Total requests')
REQUEST_DURATION = Histogram('gradio_request_duration_seconds', 'Latency')
start_http_server(8000)
def monitor_request(func):
def wrapper(*args, **kwargs):
start = time.time()
REQUEST_COUNT.inc()
try:
result = func(*args, **kwargs)
REQUEST_DURATION.observe(time.time() - start)
logging.info(f"{func.__name__} took {time.time()-start:.2f}s")
return result
except Exception as e:
logging.error(f"Error in {func.__name__}: {e}")
raise
return wrapper