Spaces:
Paused
Paused
Upload core/performance.py with huggingface_hub
Browse files- core/performance.py +5 -3
core/performance.py
CHANGED
|
@@ -18,7 +18,9 @@ logger = logging.getLogger(__name__)
|
|
| 18 |
# Prometheus Metrics
|
| 19 |
http_requests_total = Counter("http_requests_total", "Total HTTP requests", ["method", "endpoint", "status"])
|
| 20 |
|
| 21 |
-
http_request_duration_seconds = Histogram(
|
|
|
|
|
|
|
| 22 |
|
| 23 |
fraud_detections_total = Counter("fraud_detections_total", "Total fraud detections", ["risk_level"])
|
| 24 |
|
|
@@ -26,7 +28,7 @@ ai_predictions_total = Counter("ai_predictions_total", "Total AI predictions mad
|
|
| 26 |
|
| 27 |
pending_cases = Gauge("pending_cases", "Number of pending fraud cases")
|
| 28 |
|
| 29 |
-
|
| 30 |
|
| 31 |
cache_hits_total = Counter("cache_hits_total", "Total cache hits", ["cache_type"])
|
| 32 |
|
|
@@ -122,7 +124,7 @@ def update_pending_cases(count: int):
|
|
| 122 |
|
| 123 |
def record_db_query(query_type: str, duration: float):
|
| 124 |
"""Record database query performance"""
|
| 125 |
-
|
| 126 |
|
| 127 |
|
| 128 |
def record_cache_hit(cache_type: str = "default"):
|
|
|
|
| 18 |
# Prometheus Metrics
|
| 19 |
http_requests_total = Counter("http_requests_total", "Total HTTP requests", ["method", "endpoint", "status"])
|
| 20 |
|
| 21 |
+
http_request_duration_seconds = Histogram(
|
| 22 |
+
"http_request_duration_seconds", "HTTP request latency", ["method", "endpoint"]
|
| 23 |
+
)
|
| 24 |
|
| 25 |
fraud_detections_total = Counter("fraud_detections_total", "Total fraud detections", ["risk_level"])
|
| 26 |
|
|
|
|
| 28 |
|
| 29 |
pending_cases = Gauge("pending_cases", "Number of pending fraud cases")
|
| 30 |
|
| 31 |
+
from core.query_monitoring import query_duration # noqa: E402
|
| 32 |
|
| 33 |
cache_hits_total = Counter("cache_hits_total", "Total cache hits", ["cache_type"])
|
| 34 |
|
|
|
|
| 124 |
|
| 125 |
def record_db_query(query_type: str, duration: float):
|
| 126 |
"""Record database query performance"""
|
| 127 |
+
query_duration.labels(operation="general", table=query_type).observe(duration)
|
| 128 |
|
| 129 |
|
| 130 |
def record_cache_hit(cache_type: str = "default"):
|