-
[OPIK-7249] [BE][FE] fix: cheap existence probe for Logs empty state (#7378)
发布于
2026-07-09 14:52:15 +00:00 - [OPIK-7249] [BE][FE] fix: cheap existence probe for Logs empty state
The project Logs page decided whether to show the "log your first trace"
onboarding by firing an auxiliary size=1 list probe (useTracesOrSpansList /
useThreadList). Even for a single row the backend builds the full
trace/span/cost/feedback aggregation across the entire project before
LIMIT 1 -- a multi-GiB, multi-second ClickHouse scan on large projects,
fired on every Logs page load (Traces, Spans and Threads tabs) and ignoring
the selected time range. Same class as #6148 / #6949.Add a minimal existence endpoint per entity and use it for the probe:
- BE: GET /v1/private/traces/exists (+thread_only) and /v1/private/spans/exists,
each a project-scoped SELECT 1 ... LIMIT 1. Deliberately minimal -- no
filters/search/time-range surface -- so the query is always a
primary-key-prunable LIMIT 1 with no full-project COUNT fallback. - FE: useTracesExist / useSpansExist / useTracesOrSpansExist hooks; the
Traces, Spans and Threads tabs derive hasProjectData from the existence
endpoint (threads via thread_only) instead of a size=1 list query.
Turns a whole-project scan into a single-row LIMIT 1 lookup. Not done by
forwarding from_time/to_time into the probe: that breaks the empty-state
(data older than the window would show onboarding) and revives the
id<->event-time mismatch that got #6949 reverted in #7007.Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com
- fix(traces): address review on Logs existence probe
- back the thread probe with trace_threads (PK-prunable) instead of
traces WHERE thread_id != '', which the sort key + bloom index can't prune - define tracesExist/spansExist rate-limit buckets in config.yml so the
@RateLimited probes are actually throttled - restore the source=sdk scope on the probes (with the ENUM_LEGACY unknown
fallback) so the Logs empty state matches the sdk-scoped list again - add project_id-form and source-scoping tests for traces and spans
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com
- docs(traces): correct stale comment on the sdk-scoped existence probe
The round-2 source=sdk restoration left the round-1 'source-agnostic' comment in TracesSpansTab, contradicting the code.
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com
Co-authored-by: Claude Opus 4.8 (1M context) noreply@anthropic.com
下载附件