feat(ui): add session id filter to request logs - #32568
Conversation
Greptile SummaryThis PR adds a
Confidence Score: 5/5Safe to merge — the change is narrowly scoped to an additive query parameter on the spend logs endpoint with no modifications to existing filter paths. The backend change adds a single optional LIKE filter that is only activated when No files require special attention.
|
| Filename | Overview |
|---|---|
| litellm/proxy/spend_tracking/spend_management_endpoints.py | Adds session_id query parameter to both /spend/logs/v2 and /spend/logs/ui (shared function), with a LIKE-based substring filter that correctly escapes %, _, and \ before binding as a SQL parameter. |
| tests/test_litellm/proxy/spend_tracking/test_spend_management_endpoints.py | Adds parameterized test covering full-id match, partial prefix match, cross-session partial match, and no-match for the new session_id filter; generalizes the shared group_by mock to support arbitrary grouping columns. |
| ui/litellm-dashboard/src/components/view_logs/log_filter_logic.tsx | Adds SESSION_ID to FILTER_KEYS, TEXT_FILTER_KEYS, defaultFilters, and the effectiveFilters → API params mapping; wiring is consistent with how other text filters are handled. |
| ui/litellm-dashboard/src/components/view_logs/filter_options.ts | Adds Session ID as a non-searchable text filter option, consistent with Key Hash and Request ID entries. |
| ui/litellm-dashboard/src/components/networking.tsx | Extends UiSpendLogsParams interface with optional session_id field. |
| ui/litellm-dashboard/src/components/view_logs/log_filter_logic.test.tsx | Adds Session ID → session_id mapping to the existing filter-key parameterization test table. |
| ui/litellm-dashboard/src/lib/http/schema.d.ts | Regenerated OpenAPI schema with session_id parameter added to both /spend/logs/v2 and /spend/logs/ui operations. |
Reviews (2): Last reviewed commit: "feat(ui): support partial match on sessi..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Since the first review: the session_id filter now does a partial (substring) match instead of exact equality, following the error_message/key_alias LIKE pattern with wildcard escaping, and the shared test mock's group_by was generalized per the earlier comment. On the CodSpeed report: the flagged benchmark exercises the completion call path, which this PR does not touch (it only adds a query parameter to the spend logs endpoint), so the regression looks like runner noise |
d043fe7 to
8a44fdd
Compare
131aa05
into
BerriAI:litellm_internal_staging
Relevant issues
Fixes #32585
Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Captured at 9a4652e against a live proxy (
python litellm/proxy/proxy_cli.py --config litellm/proxy/dev_config.yaml --detailed_debug --use_v2_migration_resolveron localhost:4000 with a local Postgres), hitting the real OpenAI API with real spendFirst, three real chat completions across two sessions, using the
x-litellm-session-idheader:Then the logs endpoint with the new
session_idfilter:UI screenshots of the new Session ID field in the Logs filter panel to follow
Type
🆕 New Feature
Changes
The Requests logs tab lets you filter by request id but not by session id, so tracking a full conversation means clicking through rows manually. This adds a Session ID filter end to end
On the backend,
/spend/logs/v2and/spend/logs/uigain asession_idquery parameter that does an exact match on thesession_idcolumn ofLiteLLM_SpendLogs(already indexed), following the exact same pattern as the existingrequest_idfilterOn the dashboard, the Logs filter panel gains a Session ID text input wired through
FILTER_KEYS, the debounced text filter list, anduiSpendLogsCall, which forwards it as thesession_idquery param.schema.d.tsis regenerated for the new parameterTests: a new endpoint test asserts that filtering by session id returns only that session's rows (the shared mock prisma helper now also supports the session-count enrichment queries, so endpoint tests can use rows that carry a
session_id), and the frontend filter mapping test table gains the Session ID tosession_idcase