Skip to content

Add INFO-level session reuse logging per request#20597

Merged
AlexsanderHamir merged 1 commit intomainfrom
litellm_log_changes_001
Feb 6, 2026
Merged

Add INFO-level session reuse logging per request#20597
AlexsanderHamir merged 1 commit intomainfrom
litellm_log_changes_001

Conversation

@AlexsanderHamir
Copy link
Collaborator

Relevant issues

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

CI (LiteLLM team)

CI status guideline:

  • 50-55 passing tests: main is stable with minor issues.
  • 45-49 passing tests: acceptable but needs attention
  • <= 40 passing tests: unstable; be careful with your merges and assess the risk.
  • Branch creation CI run
    Link:

  • CI run for the last commit
    Link:

  • Merge / cherry-pick CI run
    Links:

Type

🧹 Refactoring

Changes

  • Log when shared aiohttp session is attached to each request
  • Log when no shared session is available
  • Visible at INFO level (production-safe)

- Log when shared aiohttp session is attached to each request
- Log when no shared session is available
- Visible at INFO level (production-safe)
@vercel
Copy link

vercel bot commented Feb 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
litellm Building Building Preview, Comment Feb 6, 2026 7:36pm

Request Review

@AlexsanderHamir AlexsanderHamir merged commit 5733f62 into main Feb 6, 2026
9 of 51 checks passed
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 6, 2026

Greptile Overview

Greptile Summary

  • Adds INFO-level logs inside add_shared_session_to_data() to report whether a shared aiohttp session was attached to each routed request.
  • Uses verbose_proxy_logger and logs the shared session object id when reuse occurs.
  • Change is localized to the proxy request routing path (litellm/proxy/route_llm_request.py).

Confidence Score: 3/5

  • This PR is mostly safe but introduces high-volume INFO logging on the hot request path.
  • Change is small and localized, but INFO-level per-request logging will reliably spam production logs under real traffic recommend downgrading/gating to avoid operational impact.
  • litellm/proxy/route_llm_request.py

Important Files Changed

Filename Overview
litellm/proxy/route_llm_request.py Adds INFO-level logging around shared aiohttp session reuse/absence in the request routing path; introduces a likely mismatch between log message intent and actual condition (can incorrectly log 'reuse' when a new per-request session is created).

Sequence Diagram

sequenceDiagram
    participant Client
    participant Proxy as LiteLLM Proxy
    participant Router as LLM Router
    participant SessionMgr as aiohttp Session Manager

    Client->>Proxy: HTTP request (LLM completion/chat)
    Proxy->>Router: route_llm_request(...)
    Router->>SessionMgr: get_shared_aiohttp_session()
    alt Shared session available
        SessionMgr-->>Router: aiohttp.ClientSession
        Router->>Router: attach session to per-request call
        Router->>Proxy: log INFO "shared session attached"
    else No shared session
        SessionMgr-->>Router: None
        Router->>Proxy: log INFO "no shared session available"
    end
    Router-->>Proxy: forward request to provider
    Proxy-->>Client: response
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines +100 to 102
from litellm._logging import verbose_proxy_logger
from litellm.proxy.proxy_server import shared_aiohttp_session

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logging is too noisy

This adds an INFO log on every request in add_shared_session_to_data, both when a shared session is present and when it isn’t. In production this will flood logs and materially increase log volume/cost, especially since the PR description calls this “production-safe”. This should be downgraded to DEBUG (or gated behind an opt-in flag / sampling) so normal traffic doesn’t emit per-request log lines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant