🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix: performance improvements on traces table (#802)
Max Deichmann381ef1d6903d
diff --git a/src/components/table/use-cases/traces.tsx b/src/components/table/use-cases/traces.tsxindex 121a0ea320..7396713d58 100644--- a/src/components/table/use-cases/traces.tsx+++ b/src/components/table/use-cases/traces.tsx@@ -118,9 +118,21 @@ export default function TracesTable({// eslint-disable-next-line react-hooks/exhaustive-deps}, [traces.isSuccess, traces.data]);- const traceFilterOptions = api.traces.filterOptions.useQuery({- projectId,- });+ // loading filter options indivdually form the remaining calls+ // traces.all should load first together with everyhting else.+ // This here happens in the backgorund.+ const traceFilterOptions = api.traces.filterOptions.useQuery(+ {+ projectId,+ },+ {+ trpc: {+ context: {+ skipBatch: true,+ },+ },+ },+ );const convertToTableRow = (trace: RouterOutput["traces"]["all"][0],diff --git a/src/server/api/routers/traces.ts b/src/server/api/routers/traces.tsindex 693b879ad3..262d49a418 100644--- a/src/server/api/routers/traces.ts+++ b/src/server/api/routers/traces.ts@@ -145,6 +145,7 @@ export const traceRouter = createTRPCRouter({LIMIT ${input.limit}OFFSET ${input.page * input.limit}`;+const traces = await ctx.prisma.$queryRaw<Array<Trace & {@@ -191,8 +192,17 @@ export const traceRouter = createTRPCRouter({projectId: input.projectId,},by: ["name"],+ // limiting to 1k trace names to avoid performance issues.+ // some users have unique names for large amounts of traces+ // sending all trace names to the FE exceeds the cloud function return size limit+ take: 1000,+ orderBy: {+ _count: {+ id: "desc",+ },+ },_count: {- _all: true,+ id: true,},});const res: TraceOptions = {@@ -201,7 +211,7 @@ export const traceRouter = createTRPCRouter({.filter((n) => n.name !== null).map((name) => ({value: name.name ?? "undefined",- count: name._count._all,+ count: name._count.id,})),};return res;