Skip to content

[fix][trace] add per-space double-query whitelist for trajectory query - #672

Open
whh935 wants to merge 2 commits into
mainfrom
feat/trajectory-double-query-whitelist
Open

whh935 wants to merge 2 commits into
mainfrom
feat/trajectory-double-query-whitelist

Conversation

@whh935

@whh935 whh935 commented Sep 21, 2026 •

Copy link
Copy Markdown
Collaborator

背景

线上 /open-api/observability/traces/trajectory 自 trajectory_metadata_config 打开全局 enable_single_query 后,对重 trace 大量返回 HTTP 200,但响应是空数据。single-query 路径一次 ListSpansRepeat 不设 SelectColumns(等价 SELECT *)、Limit 1000,单页体积易超 maxBytes(被吞成 200 空)或压垮 ClickHouse。

改动

给 TrajectoryMetadataConfig 增加 space 级白名单 enable_double_query_spaces:命中的 workspace_id 强制走 double-query 路径,即使全局 enable_single_query=true。用于对受影响 space 精准止血,同时不影响其他 space 的 single-query 行为。

  • config.go:新增 EnableDoubleQuerySpaces []int64 字段 + nil-safe IsDoubleQueryEnabled(workspaceID)。字段缺失时为 nil slice,slices.Contains 返回 false,向前兼容。
  • trace_service.go:GetTrajectories 分流改为 IsSingleQueryEnabled() && !IsDoubleQueryEnabled(workspaceID) 才走 single。
  • 补充 TestTrajectoryMetadataConfig_IsDoubleQueryEnabled 单测。

配置用法

{
  "enable_single_query": true,
  "enable_double_query_spaces": [7578826558572331009]
}

Add EnableDoubleQuerySpaces whitelist to TrajectoryMetadataConfig so that
whitelisted spaces always fall back to the double-query path even when
enable_single_query is globally on. The single-query path issues a single
SELECT * with Limit 1000, which can exceed maxBytes (swallowed into HTTP 200
empty) or overload ClickHouse (folded into an rpc error) for heavy traces.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@codecov

codecov Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #672   +/-   ##
=======================================
  Coverage   78.84%   78.84%           
=======================================
  Files         707      707           
  Lines       87896    87900    +4     
=======================================
+ Hits        69298    69308   +10     
+ Misses      14607    14604    -3     
+ Partials     3991     3988    -3     
Flag Coverage Δ
unittests 78.84% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...es/observability/domain/component/config/config.go 58.33% <100.00%> (+5.20%) ⬆️
...bservability/domain/trace/service/trace_service.go 90.04% <100.00%> (ø)

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 71c4cb4...322229f. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

cuichen01
cuichen01 previously approved these changes Sep 21, 2026
@whh935 whh935 closed this Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants