Skip to content

Metric Logging #129

@aditeyabaral

Description

@aditeyabaral

📌 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 handlersenhancementNew feature or request

Projects

Status

In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions