mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-22 00:31:44 +00:00
perf(log_db_metrics): fast path in _is_exception_related_to_db to avoid Prisma import
Check exception module (prisma/httpx) before importing Prisma, which is expensive on first load (~12s). Non-DB exceptions return False without import.
This commit is contained in:
parent
0779d24f8f
commit
79bdbd2506
1 changed files with 7 additions and 1 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue