Add INFO-level session reuse logging per request

- Log when shared aiohttp session is attached to each request
- Log when no shared session is available
- Visible at INFO level (production-safe)
This commit is contained in:
Alexsander Hamir 2026-02-06 11:35:25 -08:00
parent b859d76cc2
commit e1273630f9

View file

@ -97,10 +97,18 @@ def add_shared_session_to_data(data: dict) -> None:
data: Dictionary to add the shared session to
"""
try:
from litellm._logging import verbose_proxy_logger
from litellm.proxy.proxy_server import shared_aiohttp_session
if shared_aiohttp_session is not None and not shared_aiohttp_session.closed:
data["shared_session"] = shared_aiohttp_session
verbose_proxy_logger.info(
f"SESSION REUSE: Attached shared aiohttp session to request (ID: {id(shared_aiohttp_session)})"
)
else:
verbose_proxy_logger.info(
"SESSION REUSE: No shared session available for this request"
)
except Exception:
# Silently continue without session reuse if import fails or session unavailable
pass