Skip to content

[OPIK-5270] [BE][T SDK][P SDK] feat: add exclude support to search traces stream endpoint#6098

Merged
andrescrz merged 1 commit intomainfrom
andrescrz/OPIK-5270-stream-exclude-feedback-scores
Apr 7, 2026
Merged

[OPIK-5270] [BE][T SDK][P SDK] feat: add exclude support to search traces stream endpoint#6098
andrescrz merged 1 commit intomainfrom
andrescrz/OPIK-5270-stream-exclude-feedback-scores

Conversation

@andrescrz
Copy link
Copy Markdown
Member

Details

Add exclude parameter to the search traces stream endpoint (POST /traces/search) and wire it through both Python and TypeScript SDKs. When exclude=["feedback_scores"] is passed, the feedback score CTE chain (~12.7 GiB pipeline overhead) is skipped entirely.

This unblocks SDK users hitting OOM on search_traces — the query was silently failing and returning 0 results because the feedback score pipeline exceeded the ClickHouse memory limit.

  • BE: Add exclude field to TraceSearchStreamRequest, wire into TraceSearchCriteria, call bindTemplateExcludeFieldVariables in findTraceStream
  • Python SDK: Add exclude param to Opik.search_traces()search_traces_with_filters() → Fern client
  • TypeScript SDK: Add exclude param to OpikClient.searchTraces()searchTracesWithFilters() → Fern client

Change checklist

  • User facing
  • Documentation update

Issues

  • OPIK-5270

AI-WATERMARK

AI-WATERMARK: yes

  • If yes:
    • Tools: Claude Code
    • Model(s): Claude Opus 4.6
    • Scope: Implementation across BE + both SDKs
    • Human verification: Code review + manual testing on customer ClickHouse instance. Verified SDK search_traces OOM was caused by feedback score pipeline (61 GiB allocation attempt). Verified the exclude parameter skips the CTEs.

Testing

  • mvn compile passes (BE)
  • npx tsc --noEmit passes (TS SDK)
  • npx vitest run tests/unit/client/client-searchTraces.test.ts — 15/15 tests pass (updated assertion for 6th exclude arg)
  • Existing stream endpoint tests (getStreamAndAssertContent) pass unchanged — exclude defaults to null (no-op)
  • Existing paginated exclude tests cover the shared bindTemplateExcludeFieldVariables code path

Documentation

N/A — the exclude parameter is documented in the SDK method docstrings and Fern-generated API docs.

🤖 Generated with Claude Code

@andrescrz andrescrz requested review from a team as code owners April 7, 2026 10:47
@github-actions github-actions bot added documentation Improvements or additions to documentation python Pull requests that update Python code java Pull requests that update Java code Backend tests Including test files, or tests related like configuration. typescript *.ts *.tsx Python SDK TypeScript SDK labels Apr 7, 2026
Copy link
Copy Markdown
Contributor

@awkoy awkoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Copy Markdown
Contributor

@BorisTkachenko BorisTkachenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BE looks good

Copy link
Copy Markdown
Contributor

@petrotiurin petrotiurin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SDK side looks good, but let's add tests

@andrescrz andrescrz merged commit ac6d82a into main Apr 7, 2026
264 of 273 checks passed
@andrescrz andrescrz deleted the andrescrz/OPIK-5270-stream-exclude-feedback-scores branch April 7, 2026 12:01
andrescrz added a commit that referenced this pull request Apr 7, 2026
andrescrz added a commit that referenced this pull request Apr 8, 2026
…point

Add `exclude` parameter to the span search stream endpoint
(POST /spans/search), matching the trace search stream endpoint
(PR #6098).

- Add `exclude` field (Set<Span.SpanField>) to SpanSearchStreamRequest
- Wire `request.exclude()` into SpanSearchCriteria in SpansResource
- Call `bindTemplateExcludeFieldVariables` in SpanDAO.findSpanStream
  (reuses the CTE guards from the previous PR)
- Update both OpenAPI specs with the exclude enum for span fields

SDK changes (Python/TypeScript) require Fern regeneration and manual
wiring of the `exclude` param through search_spans/searchSpans methods.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
andrescrz added a commit that referenced this pull request Apr 8, 2026
…point

Add `exclude` parameter to the span search stream endpoint
(POST /spans/search), matching the trace search stream endpoint
(PR #6098).

- Add `exclude` field (Set<Span.SpanField>) to SpanSearchStreamRequest
- Wire `request.exclude()` into SpanSearchCriteria in SpansResource
- Call `bindTemplateExcludeFieldVariables` in SpanDAO.findSpanStream
  (reuses the CTE guards from the previous PR)
- Update both OpenAPI specs with the exclude enum for span fields

SDK changes (Python/TypeScript) require Fern regeneration and manual
wiring of the `exclude` param through search_spans/searchSpans methods.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
andrescrz added a commit that referenced this pull request Apr 8, 2026
…point

Add `exclude` parameter to the span search stream endpoint
(POST /spans/search), matching the trace search stream endpoint
(PR #6098).

- Add `exclude` field (Set<Span.SpanField>) to SpanSearchStreamRequest
- Wire `request.exclude()` into SpanSearchCriteria in SpansResource
- Call `bindTemplateExcludeFieldVariables` in SpanDAO.findSpanStream
  (reuses the CTE guards from the previous PR)
- Update both OpenAPI specs with the exclude enum for span fields

SDK changes (Python/TypeScript) require Fern regeneration and manual
wiring of the `exclude` param through search_spans/searchSpans methods.
andrescrz added a commit that referenced this pull request Apr 8, 2026
…ans stream endpoint (#6133)

* [OPIK-5270] [BE] feat: add exclude support to search spans stream endpoint

Add `exclude` parameter to the span search stream endpoint
(POST /spans/search), matching the trace search stream endpoint
(PR #6098).

- Add `exclude` field (Set<Span.SpanField>) to SpanSearchStreamRequest
- Wire `request.exclude()` into SpanSearchCriteria in SpansResource
- Call `bindTemplateExcludeFieldVariables` in SpanDAO.findSpanStream
  (reuses the CTE guards from the previous PR)
- Update both OpenAPI specs with the exclude enum for span fields

SDK changes (Python/TypeScript) require Fern regeneration and manual
wiring of the `exclude` param through search_spans/searchSpans methods.

* Fern generation

* feat(sdk): wire exclude param through Python/TypeScript SDKs and add tests

* fix(e2e): wait for spans to be ingested before asserting in span-search

Spans are created as children of traces and may not be immediately
available in ClickHouse when the search runs. Use waitForAtLeast
to poll until all expected spans are indexed, matching the fixture's
waitForTracesVisible pattern for traces.

- Add wait_for_at_least/wait_for_timeout to spans.py route
- Add waitForAtLeast/waitForTimeout to test-helper-client searchSpans
- Use waitForAtLeast: totalSpans in both test steps

* Addressed PR review comments

* test(python): add unit tests for exclude param propagation in search_spans and search_traces

Addresses review feedback from petrotiurin.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backend documentation Improvements or additions to documentation java Pull requests that update Java code Python SDK python Pull requests that update Python code tests Including test files, or tests related like configuration. TypeScript SDK typescript *.ts *.tsx

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants