Skip to content

Conversation

@YarivHashaiComet
Copy link
Collaborator

Details

This PR adds bulk tag operations for traces, spans, and threads, removing the previous 10-item limitation and enabling users to tag up to 1000 items at once.

Backend Changes

  • Added three new batch tag update endpoints:
    • PATCH /v1/private/traces/batch - Batch update tags for traces
    • PATCH /v1/private/spans/batch - Batch update tags for spans
    • PATCH /v1/private/traces/threads/batch - Batch update tags for threads
  • Implemented TraceBatchTagUpdate, SpanBatchTagUpdate, and TraceThreadBatchTagUpdate DTOs
  • Added tag merge logic: mergeTags parameter allows merging with existing tags or replacing them
  • Maximum batch size: 1000 items per request
  • Added 17 comprehensive resource-level tests

Frontend Changes

  • Created batch update mutation hooks: useTraceBatchUpdateMutation, useSpanBatchUpdateMutation, useThreadBatchUpdateMutation
  • Updated AddTagDialog to use batch operations and removed the 10-item limit
  • Added batch tag support for threads in ThreadsActionsPanel and ThreadsTab
  • Consistent UX across all entity types (traces, spans, threads)

Change checklist

  • User facing
  • Documentation update (OpenAPI spec)

Issues

  • Resolves OPIK-2497

Testing

  • ✅ Backend compiles successfully
  • ✅ 17 new resource-level tests added for batch operations
  • ✅ Tests cover happy path, validation, edge cases, and error conditions
  • ✅ Frontend linting passes
  • Manual testing: Successfully added tags to 100+ traces, spans, and threads

Documentation

  • Updated OpenAPI specification with new batch tag endpoints
  • All three endpoints support merge_tags parameter for flexible tag management

@YarivHashaiComet YarivHashaiComet force-pushed the yariv-h/OPIK-2497-bulk-tag-operations-traces-spans-threads branch from 83f159f to e59dbc9 Compare November 3, 2025 15:56
@github-actions
Copy link
Contributor

github-actions bot commented Nov 3, 2025

- Changed paths from /batch to /batch/tags for traces and spans
- Changed path from /threads/batch to /threads/batch/tags
- Renamed methods from batchUpdate to batchUpdateTags
- Updated operationIds to batchUpdateTracesTags, batchUpdateSpansTags, batchUpdateThreadsTags
- Updated frontend API calls to use new paths
- Updated test helpers to use new paths
- Updated log messages to be more specific about tag updates
@github-actions
Copy link
Contributor

github-actions bot commented Nov 3, 2025

Backend Tests Results

  267 files    267 suites   46m 11s ⏱️
5 300 tests 5 292 ✅ 7 💤 1 ❌
5 264 runs  5 256 ✅ 7 💤 1 ❌

For more details on these failures, see this check.

Results for commit 1cac7b5.

♻️ This comment has been updated with latest results.

Reduced duplication by combining merge/replace tests into single parameterized test
@github-actions
Copy link
Contributor

github-actions bot commented Nov 3, 2025

@andrescrz
Copy link
Member

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.

Copy link
Member

@andrescrz andrescrz left a 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.

@JsonIgnoreProperties(ignoreUnknown = true)
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
@Schema(description = "Request to batch update tags for multiple spans")
public record SpanBatchTagUpdate(
Copy link
Member

Choose a reason for hiding this comment

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

Generally, these new endpoints shouldn't be tied to just tags. We might use them to update other fields in batches for spans, traces and threads, not just for tags.

We can't have an endpoint per field, so make them neutral. We will reuse them.

Review this across this whole PR: request and other objects, resource and paths, service, DAO, tests etc.

}

@WithSpan
public Flux<Span> getByIds(@NonNull Set<UUID> ids) {
Copy link
Member

Choose a reason for hiding this comment

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

The general convention for our patching endpoints is to query at the DAO level, not at the service level. That includes batch endpoints. Please see other endpoints as an example.

if (!mergeTags || batchUpdate.update().tags() == null) {
// Simple case: apply the same update to all spans
return Flux.fromIterable(batchUpdate.ids())
.flatMap(id -> update(id, batchUpdate.update()))
Copy link
Member

Choose a reason for hiding this comment

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

We can't do individual update up to the batch limit, due to performance and scalability reasons.

In addition, it defeats the purpose of implementing batch endpoints.

Let's discuss if we really need the merge functionality for tags as in the past we discussed overwriting them. If so, we could delegate to the DAO.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@andrescrz - just doubled checked it with product - we want to append

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

will fix the batch opperation and will move it to the dao

Copy link
Member

Choose a reason for hiding this comment

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

This is an auto-generated file. Please do not edit manually.

…or bulk update chunk size and stream buffer size. Update DAO implementations to utilize these new configuration parameters for improved performance in bulk operations.
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