diff --git a/litellm/proxy/db/log_db_metrics.py b/litellm/proxy/db/log_db_metrics.py index 5c795155324..33e45291ee3 100644 --- a/litellm/proxy/db/log_db_metrics.py +++ b/litellm/proxy/db/log_db_metrics.py @@ -103,9 +103,15 @@ def log_db_metrics(func): def _is_exception_related_to_db(e: Exception) -> bool: """ - Returns True if the exception is related to the DB + Returns True if the exception is related to the DB (PrismaError, httpx connection/timeout). + Uses a fast path: if the exception is not from prisma or httpx modules, return False + without importing Prisma (which is expensive ~12s on first load). """ + mod = type(e).__module__ + if not (mod.startswith("prisma") or mod.startswith("httpx")): + return False + import httpx from prisma.errors import PrismaError