🪢 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: fix traceid filter for observations by id clickhouse query (#6828)
Max Deichmanndcc5bf9c6e13
diff --git a/packages/shared/src/server/repositories/observations.ts b/packages/shared/src/server/repositories/observations.tsindex bcbfb0e0cd..30c70223c8 100644--- a/packages/shared/src/server/repositories/observations.ts+++ b/packages/shared/src/server/repositories/observations.ts@@ -428,6 +428,7 @@ const getObservationByIdInternal = async ({...(startTime? { startTime: convertDateToClickhouseDateTime(startTime) }: {}),+ ...(traceId ? { traceId } : {}),},tags: {feature: "tracing",diff --git a/web/src/__tests__/async/repositories/observation-repository.servertest.ts b/web/src/__tests__/async/repositories/observation-repository.servertest.tsindex c60e304da0..5b260ccac3 100644--- a/web/src/__tests__/async/repositories/observation-repository.servertest.ts+++ b/web/src/__tests__/async/repositories/observation-repository.servertest.ts@@ -68,13 +68,16 @@ describe("Clickhouse Observations Repository Test", () => {projectId,fetchWithInputOutput: true,});+if (!result) {throw new Error("Observation not found");}+expect(result.id).toEqual(observation.id);expect(result.traceId).toEqual(observation.trace_id);expect(result.projectId).toEqual(observation.project_id);expect(result.type).toEqual(observation.type);+expect(result.metadata).toEqual(observation.metadata);expect(result.createdAt).toEqual(new Date(observation.created_at));expect(result.updatedAt).toEqual(new Date(observation.updated_at));@@ -97,6 +100,59 @@ describe("Clickhouse Observations Repository Test", () => {expect(result.outputUsage).toEqual(5678);expect(result.totalUsage).toEqual(6912);});++ it("should return an observation if exists by traceId", async () => {+ const observationId = v4();+ const traceId = v4();++ const observation = createObservation({+ id: observationId,+ trace_id: traceId,+ project_id: projectId,+ type: "sample_type",+ metadata: {},+ provided_usage_details: { input: 1234, output: 5678, total: 6912 },+ provided_cost_details: { input: 100, output: 200, total: 300 },+ usage_details: { input: 1234, output: 5678, total: 6912 },+ cost_details: { input: 100, output: 200, total: 300 },+ is_deleted: 0,+ created_at: Date.now(),+ updated_at: Date.now(),+ start_time: Date.now(),+ event_ts: Date.now(),+ name: "sample_name",+ level: "sample_level",+ status_message: "sample_status",+ version: "1.0",+ input: "sample_input",+ output: "sample_output",+ provided_model_name: "sample_model",+ internal_model_id: "sample_internal_model_id",+ model_parameters: '{"something":"sample_param"}',+ total_cost: 300,+ prompt_id: "sample_prompt_id",+ prompt_name: "sample_prompt_name",+ prompt_version: 1,+ end_time: Date.now(),+ completion_start_time: Date.now(),+ });++ await createObservationsCh([observation]);++ const result = await getObservationById({+ id: observationId,+ projectId,+ traceId,+ fetchWithInputOutput: true,+ });+ if (!result) {+ throw new Error("Observation not found");+ }+ expect(result.id).toEqual(observation.id);+ expect(result.traceId).toEqual(observation.trace_id);+ expect(result.projectId).toEqual(observation.project_id);+ expect(result.type).toEqual(observation.type);+ });it("should return an observation view", async () => {const observationId = v4();const traceId = v4();