-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[OPIK-2497] [BE] [FE] Add bulk tag operations for traces, spans and threads #3920
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
base: main
Are you sure you want to change the base?
[OPIK-2497] [BE] [FE] Add bulk tag operations for traces, spans and threads #3920
Conversation
83f159f to
e59dbc9
Compare
|
🌿 Preview your docs: https://opik-preview-16b57c7e-3e71-4ffa-94fd-9b35c46744b2.docs.buildwithfern.com/docs/opik The following broken links where found: Page: Page: Page: Page: Page: https://opik-preview-16b57c7e-3e71-4ffa-94fd-9b35c46744b2.docs.buildwithfern.com/docs/opik/integrations/gretel Page: https://opik-preview-16b57c7e-3e71-4ffa-94fd-9b35c46744b2.docs.buildwithfern.com/docs/opik/integrations/gretel/ |
|
🌿 Preview your docs: https://opik-preview-e0aa25e5-f681-4d62-b690-25f6aa194226.docs.buildwithfern.com/docs/opik The following broken links where found: Page: https://opik-preview-e0aa25e5-f681-4d62-b690-25f6aa194226.docs.buildwithfern.com/docs/opik/integrations/gretel Page: https://opik-preview-e0aa25e5-f681-4d62-b690-25f6aa194226.docs.buildwithfern.com/docs/opik/integrations/gretel/ |
|
🌿 Preview your docs: https://opik-preview-9b77cd39-88fa-46c6-99e4-cc329e42e5c0.docs.buildwithfern.com/docs/opik The following broken links where found: Page: https://opik-preview-9b77cd39-88fa-46c6-99e4-cc329e42e5c0.docs.buildwithfern.com/docs/opik/integrations/gretel Page: https://opik-preview-9b77cd39-88fa-46c6-99e4-cc329e42e5c0.docs.buildwithfern.com/docs/opik/integrations/gretel/ Page: https://opik-preview-9b77cd39-88fa-46c6-99e4-cc329e42e5c0.docs.buildwithfern.com/docs/opik/integrations/gretel Page: https://opik-preview-9b77cd39-88fa-46c6-99e4-cc329e42e5c0.docs.buildwithfern.com/docs/opik/integrations/gretel/ Page: Page: Page: Page: |
Backend Tests Results 295 files 295 suites 50m 32s ⏱️ Results for commit 4a1d0f8. ♻️ This comment has been updated with latest results. |
|
Let's check the overlap with this other PR: There was a PR review there and feedback comments, and also a decent implementation that you can use as a base. |
andrescrz
left a comment
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.
Left a preliminary review on this draft, with the stuff to be addressed.
apps/opik-backend/src/main/java/com/comet/opik/api/SpanBatchTagUpdate.java
Outdated
Show resolved
Hide resolved
apps/opik-backend/src/main/java/com/comet/opik/domain/SpanDAO.java
Outdated
Show resolved
Hide resolved
apps/opik-backend/src/main/java/com/comet/opik/domain/SpanService.java
Outdated
Show resolved
Hide resolved
1eb38ea to
e49b65b
Compare
SDK E2E Tests Results0 tests 0 ✅ 0s ⏱️ Results for commit 4a1d0f8. ♻️ This comment has been updated with latest results. |
107a809 to
459824a
Compare
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.
Pull Request Overview
This PR adds batch tag operations for traces, spans, and threads, removing the 10-item limitation and enabling users to tag up to 1000 items simultaneously. The implementation includes both backend API endpoints and frontend UI integration.
Key changes:
- New batch update endpoints for traces, spans, and threads with configurable tag merge/replace behavior
- Comprehensive test coverage with 17 new tests covering success paths, validation, and edge cases
- Frontend batch mutation hooks replacing individual update operations
Reviewed Changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
ThreadsTab.tsx |
Added callback prop to clear selection after successful tag operation |
ThreadsActionsPanel.tsx |
Integrated "Add tags" button and dialog for threads, reordered buttons to accommodate new feature |
AddTagDialog.tsx |
Refactored to use batch operations, removed 10-item limit, added thread support |
useTraceBatchUpdateMutation.ts |
New mutation hook for batch trace tag updates |
useThreadBatchUpdateMutation.ts |
New mutation hook for batch thread tag updates |
useSpanBatchUpdateMutation.ts |
New mutation hook for batch span tag updates |
TracesResourceTest.java |
Added comprehensive test suite for trace batch operations |
SpansResourceTest.java |
Added test suite for span batch operations |
TraceResourceClient.java |
Added client methods for batch update API calls |
SpanResourceClient.java |
Added client method for span batch updates |
BatchOperationsConfig.java |
Added analytics config for bulk update chunk sizes and streaming buffer |
TraceThreadService.java |
Implemented batch update logic with tag merging support |
TraceThreadIdService.java |
Added method to retrieve thread ID models by thread model IDs |
TraceThreadDAO.java |
Implemented bulk tag update queries with chunking for efficient ClickHouse operations |
TraceService.java |
Implemented batch update orchestration with tag merge logic |
TraceDAO.java |
Added bulk tag update implementation with StringTemplate error suppression |
SpanService.java |
Implemented span batch update with tag merging |
SpanDAO.java |
Added span bulk update queries with chunking support |
TracesResource.java |
Added REST endpoints for trace and thread batch updates |
SpansResource.java |
Added REST endpoint for span batch updates |
TraceThreadBatchUpdate.java |
DTO for thread batch update requests |
TraceBatchUpdate.java |
DTO for trace batch update requests |
SpanBatchUpdate.java |
DTO for span batch update requests |
config.yml |
Added configuration for bulk update chunk size and stream buffer size |
apps/opik-backend/src/main/java/com/comet/opik/domain/TraceDAO.java
Outdated
Show resolved
Hide resolved
apps/opik-frontend/src/components/pages-shared/traces/AddTagDialog/AddTagDialog.tsx
Outdated
Show resolved
Hide resolved
apps/opik-backend/src/main/java/com/comet/opik/domain/threads/TraceThreadDAO.java
Outdated
Show resolved
Hide resolved
apps/opik-backend/src/main/java/com/comet/opik/domain/TraceDAO.java
Outdated
Show resolved
Hide resolved
apps/opik-backend/src/main/java/com/comet/opik/domain/SpanDAO.java
Outdated
Show resolved
Hide resolved
|
✅ Test environment is now available! Access Information
The deployment has completed successfully and the version has been verified. |
andriidudar
left a comment
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.
The frontend side looks very good — great work! 👏
I’ve left two comments; it’s up to you to decide how you’d like to proceed with them.
Frontend part is approved ✅
apps/opik-frontend/src/components/pages-shared/traces/AddTagDialog/AddTagDialog.tsx
Outdated
Show resolved
Hide resolved
apps/opik-frontend/src/components/pages/TracesPage/ThreadsTab/ThreadsTab.tsx
Outdated
Show resolved
Hide resolved
andrescrz
left a comment
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.
This new revision still has a hybrid approach were data is queried and service level and then queried again and inserted.
In addition, it has a chunking mechanism that increases complexity without providing benefits.
These endpoints can be implemented in a much simpler manner, specially because they don't provide concurrency guarantees (like the individual create/update span and trace etc. endpoints).
I gave guidance to accomplish this.
apps/opik-backend/src/main/java/com/comet/opik/domain/SpanDAO.java
Outdated
Show resolved
Hide resolved
apps/opik-backend/src/main/java/com/comet/opik/domain/SpanDAO.java
Outdated
Show resolved
Hide resolved
apps/opik-backend/src/main/java/com/comet/opik/domain/TraceDAO.java
Outdated
Show resolved
Hide resolved
apps/opik-backend/src/main/java/com/comet/opik/domain/SpanDAO.java
Outdated
Show resolved
Hide resolved
| } | ||
|
|
||
| @WithSpan | ||
| public Mono<Void> batchUpdate(@NonNull SpanBatchUpdate batchUpdate) { |
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.
There's a problem with this method, which is derived from using SpanUpdate directly.
- You need to make sure that validations in
SpanUpdatedon't harm you e.g: projectName and projectId. - Then you might need to extend the validations from tag here to other fields if needed. Although I recommend delegating that to the DAO (see other update with insert + select queries).
- The most important suggestion here is ignoring key fields, such as project, traceId etc. in the update operation.
- Finally and related to 3, you could create a light-weight flavour of
SpanUpdateif needed.
In summary, this method shouldn't do much beyond delegating to the DAO.
apps/opik-backend/src/main/java/com/comet/opik/domain/TraceDAO.java
Outdated
Show resolved
Hide resolved
apps/opik-backend/src/main/java/com/comet/opik/infrastructure/BatchOperationsConfig.java
Outdated
Show resolved
Hide resolved
| @Nested | ||
| @DisplayName("Batch Update Spans Tags:") | ||
| @TestInstance(TestInstance.Lifecycle.PER_CLASS) | ||
| class BatchUpdateSpans { |
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.
These test classes grew too long, we're actively splitting them now. Please create the tests for the new endpoints in a separated test file.
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.
Please add your new tests to a separated class for BatchUpdateSpans etc.
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.
This is very close to be ready. There are some considerations:
- Please use string templates for your queries, this is a must in the service instead of replacing raw strings. This is trivial to change.
- Your batch update endpoints only allow updating
tags. It would be a pity to only deliver that, knowing that it would give us headaches in the future and that supporting any updatable field requires just a few small changes. Actually, the tests is what takes more effort as there are many updatable fields, but we could compromise on those tests. - Please do not add tests to the existing classes, create new separated files. We've been having troubles lately with their size and @thiagohora has been splitting them. Let's not go backwards with this problem.
Let me know if any question.
apps/opik-backend/src/main/java/com/comet/opik/domain/SpanDAO.java
Outdated
Show resolved
Hide resolved
apps/opik-backend/src/main/java/com/comet/opik/domain/SpanDAO.java
Outdated
Show resolved
Hide resolved
apps/opik-backend/src/main/java/com/comet/opik/domain/SpanService.java
Outdated
Show resolved
Hide resolved
apps/opik-backend/src/main/java/com/comet/opik/domain/threads/TraceThreadDAO.java
Outdated
Show resolved
Hide resolved
| @Nested | ||
| @DisplayName("Batch Update Spans Tags:") | ||
| @TestInstance(TestInstance.Lifecycle.PER_CLASS) | ||
| class BatchUpdateSpans { |
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.
Please add your new tests to a separated class for BatchUpdateSpans etc.
apps/opik-backend/src/test/java/com/comet/opik/api/resources/v1/priv/SpansResourceTest.java
Outdated
Show resolved
Hide resolved
9c6acb5 to
4a1d0f8
Compare
Details
https://www.loom.com/share/ea176178bbae43338a8247ff45605c8e
This PR implements batch tag update operations for traces, spans, and threads, allowing users to efficiently update tags for multiple items at once.
Backend Changes
SpansResourceandTracesResourcefor traces, spans, and threadsSpanBatchUpdate,TraceBatchUpdate, andTraceThreadBatchUpdateSpanDAO,TraceDAO, andTraceThreadDAOto handle batch tag operations efficientlySpanService,TraceService, andTraceThreadServicefor batch updatesBatchOperationsConfigfor configurable batch operation limitsSpansResourceTestandTracesResourceTestFrontend Changes
useSpanBatchUpdateMutationuseTraceBatchUpdateMutationuseThreadBatchUpdateMutationAddTagDialogcomponent to support batch operationsThreadsActionsPanelto integrate batch tag updatesConfiguration
config.ymlwith size limits and validationChange checklist
Issues
Testing
Documentation
BatchOperationsConfigsettings