fix(traces): include observation IO in legacy trace JSON download - #15451
Open
Souravrajvi0 wants to merge 3 commits into
Open
fix(traces): include observation IO in legacy trace JSON download#15451Souravrajvi0 wants to merge 3 commits into
Souravrajvi0 wants to merge 3 commits into
Conversation
Legacy trace downloads serialized lightweight observations from the trace detail query, which omitted input, output, and metadata. Fetch full observation IO on download via includeObservationIO and add unit coverage. Fixes langfuse#15337
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes #15337
Legacy trace JSON downloads serialized observations from
traces.byIdWithObservationsAndScores, which intentionally loads observations withincludeIO: falseand stripsinput/outputfor the lightweight trace detail view. The download button reused that payload client-side, so exported observations hadinput: null,output: null, and empty metadata even though the observation detail panel showed the full data.Root cause
byIdWithObservationsAndScoresqueries ClickHouse withincludeIO: falseinputandoutputon each observation before returning!v4Beta) calleddownloadLegacyTraceAsJson({ trace, observations })with that in-memory payload/api/traces/[traceId]/download, which loads full observation IO server-sideProposed changes
web/src/server/api/routers/traces.ts: add optionalincludeObservationIOinput; when true, query observations withincludeIO: trueand stringify IO for exportweb/src/components/trace/components/_layout/TracePanelNavigationHeader.tsx: legacy download now fetches trace data withincludeObservationIO: truebefore serializing JSONweb/src/features/traces/server/mapTraceDetailObservations.ts: extract observation mapping helper used by the trace routerweb/src/__tests__/server/mapTraceDetailObservations.servertest.ts: ClickHouse integration coverage for the export pathweb/src/features/traces/server/mapTraceDetailObservations.unit.test.ts: unit coverage for stripped vs exported observation IOImpacted packages
webType of change
Mandatory Tasks
Checklist
pnpm run format)npm run lint)Testing
Verified on the local VM against running Docker infra (
postgres,clickhouse,redis,minio):Results:
mapTraceDetailObservations.unit.test.ts: 2 passedmapTraceDetailObservations.servertest.ts: 1 passed (writes to ClickHouse, verifies exportedinput,output, andmetadata)Manual verification still recommended in the UI:
input,output, andmetadatashown in the observation detail panel