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:
Vectry
2026-02-09 23:36:28 +00:00
parent 3fe9013838
commit 21b4f9f316
7 changed files with 1677 additions and 23 deletions

View 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}
/>
);
}