feat: LangChain auto-instrumentation + dashboard UI
- LangChain: AgentLensCallbackHandler with auto-span creation for LLM calls, tool calls, chains, and agent decision logging - Dashboard: trace list with search, status filters, pagination - Dashboard: trace detail with Decision/Span/Event tabs - Dashboard: sidebar layout, responsive design, dark theme
This commit is contained in:
63
apps/web/src/app/dashboard/page.tsx
Normal file
63
apps/web/src/app/dashboard/page.tsx
Normal file
@@ -0,0 +1,63 @@
|
||||
import { TraceList } from "@/components/trace-list";
|
||||
|
||||
interface TracesResponse {
|
||||
traces: Array<{
|
||||
id: string;
|
||||
name: string;
|
||||
status: "RUNNING" | "COMPLETED" | "ERROR";
|
||||
startedAt: string;
|
||||
endedAt: string | null;
|
||||
durationMs: number | null;
|
||||
tags: string[];
|
||||
metadata: Record<string, unknown>;
|
||||
_count: {
|
||||
decisionPoints: number;
|
||||
spans: number;
|
||||
events: number;
|
||||
};
|
||||
}>;
|
||||
total: number;
|
||||
page: number;
|
||||
limit: number;
|
||||
totalPages: number;
|
||||
}
|
||||
|
||||
async function getTraces(
|
||||
limit = 50,
|
||||
page = 1
|
||||
): Promise<TracesResponse> {
|
||||
try {
|
||||
const res = await fetch(
|
||||
`http://localhost:3000/api/traces?limit=${limit}&page=${page}`,
|
||||
{ cache: "no-store" }
|
||||
);
|
||||
|
||||
if (!res.ok) {
|
||||
throw new Error(`Failed to fetch traces: ${res.status}`);
|
||||
}
|
||||
|
||||
return res.json();
|
||||
} catch (error) {
|
||||
console.error("Error fetching traces:", error);
|
||||
return {
|
||||
traces: [],
|
||||
total: 0,
|
||||
page: 1,
|
||||
limit,
|
||||
totalPages: 0,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export default async function DashboardPage() {
|
||||
const data = await getTraces(50, 1);
|
||||
|
||||
return (
|
||||
<TraceList
|
||||
initialTraces={data.traces}
|
||||
initialTotal={data.total}
|
||||
initialTotalPages={data.totalPages}
|
||||
initialPage={data.page}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user