Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

Merge pull request #40737 from BerriAI/litellm_logs_user_email_display

ryan-crabbe-berri2332d3f18310
diff --cc ui/litellm-dashboard/src/components/view_logs/RequestLogsTableColumns.test.tsx
index 626d290e0e8,08853814269..4d451a9c7b9
--- a/ui/litellm-dashboard/src/components/view_logs/RequestLogsTableColumns.test.tsx
+++ b/ui/litellm-dashboard/src/components/view_logs/RequestLogsTableColumns.test.tsx
@@@ -73,59 -73,29 +73,80 @@@ describe("Cost column", () =>
expect(screen.queryByText("$0.010000")).not.toBeInTheDocument();
expect(screen.getByText("session total")).toBeInTheDocument();
});
+
+ it("does not label the per-call spend a session total when the aggregate is unavailable", () => {
+ const rowWithoutAggregate: Partial<LogEntry> = {
+ request_id: "req-session-no-aggregate",
+ spend: 0.01,
+ session_id: "sess-1",
+ session_total_count: 3,
+ };
+ renderRows([logEntry(rowWithoutAggregate)]);
+
+ expect(screen.getByText("$0.010000")).toBeInTheDocument();
+ expect(screen.queryByText("session total")).not.toBeInTheDocument();
+ });
+});
+
+describe("Duration column", () => {
+ const sessionRow: Partial<LogEntry> = {
+ request_id: "req-session-duration",
+ request_duration_ms: 1200,
+ session_id: "sess-1",
+ session_total_count: 3,
+ };
+
+ it("shows the summed session duration, not the representative call's duration, for a multi-round session", () => {
+ const aggregatedRow: Partial<LogEntry> = { ...sessionRow, session_total_duration_ms: 5400 };
+ renderRows([logEntry(aggregatedRow)]);
+
+ expect(screen.getByText("5.40")).toBeInTheDocument();
+ expect(screen.queryByText("1.20")).not.toBeInTheDocument();
+ expect(screen.getByText("session total")).toBeInTheDocument();
+ });
+
+ it("does not label the per-call duration a session total when the aggregate is unavailable", () => {
+ renderRows([logEntry(sessionRow)]);
+
+ expect(screen.getByText("1.20")).toBeInTheDocument();
+ expect(screen.queryByText("session total")).not.toBeInTheDocument();
+ });
+
+ it("shows the call's own duration for a single-call session", () => {
+ const singleCallRow: Partial<LogEntry> = {
+ ...sessionRow,
+ request_id: "req-single-duration",
+ session_id: "sess-2",
+ session_total_count: 1,
+ session_total_duration_ms: 1200,
+ };
+ renderRows([logEntry(singleCallRow)]);
+
+ expect(screen.getByText("1.20")).toBeInTheDocument();
+ });
});
+ describe("Internal User column", () => {
+ const emailById: Record<string, string> = { "106514937785257944828": "[email protected]" };
+ const deps = { ...noopDeps, resolveUserEmail: (userId: string) => emailById[userId] };
+
+ it("shows the user's email instead of the raw id, with both in the tooltip", async () => {
+ const user = userEvent.setup();
+ renderRows([logEntry({ request_id: "req-known-user", user: "106514937785257944828" })], deps);
+
+ const emailCell = screen.getByText("[email protected]");
+ expect(screen.queryByText("106514937785257944828")).not.toBeInTheDocument();
+ await user.hover(emailCell);
+ expect(await screen.findByText("[email protected] (106514937785257944828)")).toBeInTheDocument();
+ });
+
+ it("falls back to the raw id when no email is known for the user", () => {
+ renderRows([logEntry({ request_id: "req-unknown-user", user: "unknown-user-id" })], deps);
+
+ expect(screen.getByText("unknown-user-id")).toBeInTheDocument();
+ });
+ });
+
describe("Tokens column", () => {
const sessionRow: Partial<LogEntry> = {
request_id: "req-session-tokens",