Repository navigation
feat(usage): cursor pagination for the aggregated key breakdown - #43195
devin-ai-integration[bot] wants to merge 12 commits into
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
This comment has been minimized.
This comment has been minimized.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
bugbot run |
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
bugbot run |
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
bugbot run |
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 014c868. Configure here.
TLDR
Problem this solves:
How it solves it:
/user/daily/activity/aggregatedand/team/daily/activity/aggregatedacceptcursormetadata.next_cursoris a keyset cursor on (spend, key), null on the last pageThis is the pagination half of #42836, rebased on top of the merged search PRs
User Flow
Before: an admin with 340 keys can only ever see the top 100 in the Usage page or the API
After: the same admin walks through all 340 keys one page at a time
metadata.next_cursor; passing it back ascursor=...returns the next 100 keys, untilnext_cursoris nullLocal run against a proxy seeded with 105 keys, first page and after "Load more keys" (recording in the Slack thread linked from the session; taken before the note was folded into the count):
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/test_litellm/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more@greptileaito re-request a review after pushing changes)Type
🆕 New Feature
Caveats (if any)
Low
total_spend,total_api_keys) are repeated on every page, not per pageLink to Devin session: https://app.devin.ai/sessions/ec188efd8ecc4cd69f8351cce1e2fe86
Open in Devin Desktop: https://app.devin.ai/desktop/session/ec188efd8ecc4cd69f8351cce1e2fe86?variant=devin
Requested by: @kerry-berri
Note
Medium Risk
Changes spend analytics SQL and new query parameters on admin usage endpoints; bounded pages limit blast radius, but incorrect cursor/keyset logic could skip or duplicate keys in the UI.
Overview
Adds cursor-based pagination for the per-key slice of aggregated daily usage so admins can load more than the top 100 keys without one huge response.
API:
/user/daily/activity/aggregatedand/team/daily/activity/aggregatedaccept an optionalcursorquery param. Responses includemetadata.next_cursor(opaque keyset on spend + api_key); invalid cursors return 400. The aggregated SQL ranks keys by spend and applies the cursor before the existingUSAGE_TOP_API_KEYS_LIMITcap; global totals and non-key rollups stay full-range.UI: Global Usage and Team Usage Key Activity show “Showing N of M keys”, a Load more keys control that passes the cursor and merges the next page into breakdowns via
mergeKeyPage, and updated networking helpers. OpenAPI snapshot and TypeScript schema reflectnext_cursorandcursor.Reviewed by Cursor Bugbot for commit 014c868. Bugbot is set up for automated code reviews on this repo. Configure here.