fix(fe): pass time range to trace list query in ThreadDetailsPanel#6541
Open
zhoufengen wants to merge 1 commit intocomet-ml:mainfrom
Open
fix(fe): pass time range to trace list query in ThreadDetailsPanel#6541zhoufengen wants to merge 1 commit intocomet-ml:mainfrom
zhoufengen wants to merge 1 commit intocomet-ml:mainfrom
Conversation
Fixes comet-ml#6148 ThreadDetailsPanel queried traces by thread_id without passing fromTime/toTime parameters, preventing ClickHouse from using index pruning on the time-based UUID id column. On large datasets this caused query timeouts (HTTP 500). Use the thread start_time and end_time (already available from useThreadById) as time bounds for the useTracesList call. Also defer the traces query until the thread data is loaded to ensure the time range is available.
Comment on lines
197
to
199
| { | ||
| enabled: Boolean(threadId), | ||
| enabled: Boolean(threadId) && !isThreadPending, | ||
| }, |
Contributor
There was a problem hiding this comment.
enabled only checks !isThreadPending, so when useThreadById errors thread is still undefined and useTracesList runs with just thread_id; should we gate on a successful thread load (e.g. enabled: Boolean(thread) / isSuccess)?
Finding type: Logical Bugs | Severity: 🟠 Medium
Want Baz to fix this for you? Activate Fixer
Other fix methods
Prompt for AI Agents:
Before applying, verify this suggestion against the current code. In
apps/opik-frontend/src/v2/pages-shared/traces/ThreadDetailsPanel/ThreadDetailsPanel.tsx
around lines 197-199, the `useTracesList` query `enabled` flag only checks
`Boolean(threadId)` and `!isThreadPending`. Refactor this to gate on a successful thread
load instead (e.g., use the `useThreadById` status/isSuccess, or require
`Boolean(thread)`), so that on error (when `thread` is undefined) the traces query does
not run without the intended `fromTime`/`toTime` time-range constraints. Ensure the
`enabled` condition and any dependent `fromTime`/`toTime` props are only applied when
the thread data is actually present.
Collaborator
|
@zhoufengen to review this PR, I would like to ask for a video showing you changes and also for checkint the comments from Baz |
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.
Summary
Fixes #6148
ThreadDetailsPanelqueries traces bythread_idwithout passingfromTime/toTimeparameters, preventing ClickHouse from using index pruning on the time-based UUIDidcolumn. On large datasets (~4.7M traces), this causes query timeouts (HTTP 500).Changes
thread.start_timeandthread.end_timeasfromTime/toTimeto theuseTracesListhook call inThreadDetailsPanelenabled: Boolean(threadId) && !isThreadPending) to ensure time range is availableTesting
useTracesListhook already supportsfromTimeandtoTimeparametersThreadtype includesstart_timeandend_timefields from the APIRelated Issues
Fixes #6148 — ThreadDetailsPanel does not pass time range to trace list query, causing slow loading