Repository navigation
feat(search): trace-level AND scope across spans (#3004) #3154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
eugeneo17
wants to merge
39
commits into
ClickHouse:main
Choose a base branch
from
CloudGeometry:feature/3004-trace-scope
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,293
−61
Open
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
05d85c4
feat(search): trace-level AND scope across spans (#3004)
eugeneo17 66a65e1
refactor(search): address review feedback on trace scope
eugeneo17 b3cfe62
Merge branch 'main' into feature/3004-trace-scope
eugeneo17 847b8fc
Merge branch 'main' into feature/3004-trace-scope
eugeneo17 08c2269
fix(search): address review findings on trace scope
eugeneo17 77a6f8f
fix(search): make exclusion filters work at trace scope
eugeneo17 16a92a3
fix(search): correct trace-scope negation and windowed-range membership
eugeneo17 79dca70
Merge remote-tracking branch 'origin/main' into feature/3004-trace-scope
eugeneo17 916499e
Merge branch 'main' into feature/3004-trace-scope
eugeneo17 74d2a6c
Merge branch 'main' into feature/3004-trace-scope
eugeneo17 9cc2dad
fix(search): keep trace scope out of delta internals and classify neg…
eugeneo17 eccbf4d
Merge branch 'main' into feature/3004-trace-scope
eugeneo17 6682dac
perf(search): reuse one SQL parser in isNegatedFilterCondition
eugeneo17 320f9b1
Merge branch 'main' into feature/3004-trace-scope
eugeneo17 e2c5d86
fix(search): use GLOBAL IN for trace-scope membership on distributed …
eugeneo17 69c5d65
fix(search): treat lucene range/group brackets as grouped in negation…
eugeneo17 a6cb1fa
fix(search): scope the new query-failed banner to trace mode
eugeneo17 a80c4a2
Merge branch 'main' into feature/3004-trace-scope
eugeneo17 989fbd9
Merge branch 'main' into feature/3004-trace-scope
eugeneo17 6c9dccc
Merge branch 'main' into feature/3004-trace-scope
eugeneo17 63f1116
Merge branch 'main' into feature/3004-trace-scope
eugeneo17 a9fedab
Merge branch 'main' into feature/3004-trace-scope
eugeneo17 afdabd9
Merge branch 'main' into feature/3004-trace-scope
eugeneo17 86a8027
Merge branch 'main' into feature/3004-trace-scope
eugeneo17 90c2442
Merge branch 'main' into feature/3004-trace-scope
eugeneo17 9d2df50
Merge remote-tracking branch 'upstream/main' into feature/3004-trace-…
eugeneo17 66e5410
fix(search): persist search scope and restore span-error retry (#3004)
eugeneo17 a48e323
Merge branch 'main' into feature/3004-trace-scope
eugeneo17 8aa2c35
fix(search): keep Trace scope through history sync, saved searches an…
eugeneo17 5f4ddba
Merge remote-tracking branch 'origin/main' into feature/3004-trace-scope
eugeneo17 06711f4
Merge remote-tracking branch 'origin/main' into feature/3004-trace-scope
eugeneo17 0fd3c03
fix(search): address trace-scope review findings
eugeneo17 d0cf978
Merge remote-tracking branch 'origin/main' into feature/3004-trace-scope
eugeneo17 ea67a50
Merge remote-tracking branch 'origin/main' into feature/3004-trace-scope
eugeneo17 c7ac108
fix(search): click the visible scope label in e2e and drop unsafe tes…
eugeneo17 46fd39b
fix(api): expose searchScope in external saved search JSON and MCP save
eugeneo17 3237b50
style(app): use the theme default for the trace scope badge
eugeneo17 add04c2
Merge remote-tracking branch 'origin/main' into feature/3004-trace-scope
eugeneo17 b68924a
fix: address review round on trace-scope negation and alert samples
eugeneo17 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| --- | ||
| '@hyperdx/common-utils': minor | ||
| '@hyperdx/app': minor | ||
| --- | ||
|
|
||
| Add a trace-level scope for search so multi-predicate `AND` can match across the | ||
| spans of a trace, not only within a single span. | ||
|
|
||
| Search gains a **Span | Trace** scope control. **Span** (the default) is | ||
| unchanged: every predicate must hold in the same span. **Trace** matches traces | ||
| where the predicates are satisfied by different spans of the same trace. Under | ||
| the hood each predicate is rewritten into its own | ||
| `TraceId IN (SELECT TraceId FROM <source> WHERE <predicate> AND <time>)` and the | ||
| parts are `AND`-composed, with the time filter pushed into every subquery. | ||
|
|
||
| Trace scope is fail-closed: it is offered only for trace sources that expose a | ||
| trace-id expression, and it resets to Span when the source is switched, so | ||
| existing searches and saved queries are unaffected. |
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import mongoose from 'mongoose'; | ||
|
|
||
| import { SavedSearch } from '@/models/savedSearch'; | ||
|
|
||
| // Mongoose strict mode silently drops paths the schema does not declare, so | ||
| // these build documents in memory (no DB) to pin that searchScope survives. | ||
| describe('SavedSearch model searchScope', () => { | ||
| const base = { | ||
| team: new mongoose.Types.ObjectId(), | ||
| source: new mongoose.Types.ObjectId(), | ||
| name: 'trace search', | ||
| where: 'ServiceName:frontend', | ||
| }; | ||
|
|
||
| it('keeps a Trace scope', () => { | ||
| const doc = new SavedSearch({ ...base, searchScope: 'trace' }); | ||
| expect(doc.searchScope).toBe('trace'); | ||
| expect(doc.validateSync()).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('leaves the scope unset for legacy saved searches', () => { | ||
| const doc = new SavedSearch(base); | ||
| expect(doc.searchScope).toBeUndefined(); | ||
| expect(doc.validateSync()).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('rejects an unknown scope', () => { | ||
| const doc = new SavedSearch({ ...base, searchScope: 'session' }); | ||
| expect(doc.validateSync()?.errors.searchScope).toBeDefined(); | ||
| }); | ||
|
|
||
| // The external API and the MCP tools serialize through toExternalJSON, so | ||
| // a Trace search read there must not come back looking like a Span one. | ||
| it('includes the scope in the external JSON', () => { | ||
| const doc = new SavedSearch({ ...base, searchScope: 'trace' }); | ||
| expect(doc.toExternalJSON().searchScope).toBe('trace'); | ||
| expect(new SavedSearch(base).toExternalJSON().searchScope).toBeUndefined(); | ||
| }); | ||
| }); |
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
External saved search drops scope
Low Severity
toExternalJSONand the MCP save payload never includesearchScope, even though the Mongoose model andSavedSearchSchemanow persist it. MCP get/save and any othertoExternalJSONconsumer omit the field, so a Trace saved search round-trips as Span through those APIs.Reviewed by Cursor Bugbot for commit c7ac108. Configure here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 46fd39b.
toExternalJSONnow returnssearchScope(documented on theSavedSearchresponse schema), so the external API and MCP get/save report a Trace search as Trace. The MCP save tool accepts an optionalsearchScope; omitted on update it keeps the stored value, likewhereLanguageandfilters. Covered by the new case inmodels/__tests__/savedSearch.test.ts.