-
Notifications
You must be signed in to change notification settings - Fork 20
Labels
apiCore FastAPI application and route handlersCore FastAPI application and route handlersenhancementNew feature or requestNew feature or request
Description
📌 Feature Summary
Add metric logging in the auth to track failures and successes
💡 Motivation
We should enable basic metric logging to track failures and successes. The logger should track metrics across the kinds of errors as well. These metrics are useful to visualize and track our errors.
🧩 Suggested Implementation
Use a metrics collector to collect metrics as a middleware layer, and then also add a route /metrics to return the values
from collections import defaultdict
from typing import Dict
import threading
class MetricsCollector:
def __init__(self):
self.lock = threading.Lock()
self.metrics = defaultdict(int)
def inc(self, key: str):
with self.lock:
self.metrics[key] += 1
def get(self) -> Dict[str, int]:
with self.lock:
return dict(self.metrics)
metrics = MetricsCollector()🧠 Estimated Complexity
Medium (Changes multiple files, some model updates)
🔗 Related Issues / PRs
No response
🧠 Additional Notes
No response
Metadata
Metadata
Assignees
Labels
apiCore FastAPI application and route handlersCore FastAPI application and route handlersenhancementNew feature or requestNew feature or request
Type
Projects
Status
In Progress