Skip to content

[OPIK-4383] [BE] Add experiment aggregate event listener and no-op publisher#5510

Open
thiagohora wants to merge 9 commits intothiagohora/OPIK-4383-redis-stream-subscriber-experiment-aggregatesfrom
thiagohora/OPIK-4383_add_experiment_aggregate_event_listener
Open

[OPIK-4383] [BE] Add experiment aggregate event listener and no-op publisher#5510
thiagohora wants to merge 9 commits intothiagohora/OPIK-4383-redis-stream-subscriber-experiment-aggregatesfrom
thiagohora/OPIK-4383_add_experiment_aggregate_event_listener

Conversation

@thiagohora
Copy link
Contributor

Details

Implements the event-driven pipeline that triggers experiment aggregation recalculation when related entities are mutated.

New event classes

  • SpansUpdated, SpansDeleted — posted by SpanService
  • FeedbackScoresCreated, FeedbackScoresUpdated, FeedbackScoresDeleted — posted by FeedbackScoreService
  • CommentsCreated, CommentsUpdated, CommentsDeleted — posted by CommentService
  • ExperimentItemsCreated, ExperimentItemsDeleted — posted by ExperimentItemService and ExperimentItemBulkIngestionService
  • ExperimentUpdated — posted by ExperimentService
  • TracesUpdated — modified to carry traceIds in addition to projectIds

New files

  • ExperimentAggregateEventListener — central Guava @EagerSingleton event bus listener that resolves experiment IDs, checks experiment status (COMPLETED/CANCELLED), and delegates to the publisher
  • ExperimentAggregationPublisher — interface + no-op stub implementation (TODO: debounce + Redis stream in follow-up PR)

Modified services

  • SpanService, FeedbackScoreService, CommentService, ExperimentItemService, ExperimentService, ExperimentItemBulkIngestionService — inject EventBus and post the appropriate events after mutations
  • ExperimentItemDAO — adds getExperimentIdsByTraceIds() and getExperimentIdsByItemIds() ClickHouse queries

Publisher status

The publisher is intentionally a no-op in this PR. The actual Redis stream enqueue with debounce will be implemented in a follow-up task once the subscriber infrastructure is merged.

Change checklist

  • User facing
  • Documentation update

Issues

  • OPIK-4383

Testing

  • ExperimentAggregateEventListenerTest covers all event types, status filtering, disabled-config guards, and traceId → experimentId resolution paths
  • Unit test mocks verify that publisher.publish() is called with the correct experiment IDs only for experiments in COMPLETED/CANCELLED status

Documentation

N/A — internal pipeline change, no API or configuration changes visible to users

@thiagohora thiagohora requested review from a team as code owners March 4, 2026 16:24
@github-actions github-actions bot added documentation Improvements or additions to documentation dependencies Pull requests that update a dependency file python Pull requests that update Python code java Pull requests that update Java code Frontend Backend tests Including test files, or tests related like configuration. typescript *.ts *.tsx Python SDK TypeScript SDK labels Mar 4, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Backend Tests Results

  451 files  +   15    451 suites  +15   1h 2m 43s ⏱️ +57s
6 922 tests +   54  6 888 ✅ +   33  13 💤 ±0  10 ❌ +10  11 🔥 +11 
5 572 runs   - 1 137  5 538 ✅  - 1 158  13 💤 ±0  10 ❌ +10  11 🔥 +11 

For more details on these failures and errors, see this check.

Results for commit 6634138. ± Comparison against base commit 4c9f6fc.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

SDK E2E Tests Results

0 tests   0 ✅  0s ⏱️
0 suites  0 💤
0 files    0 ❌

Results for commit 2d80a7d.

♻️ This comment has been updated with latest results.

@thiagohora thiagohora force-pushed the thiagohora/OPIK-4383_add_experiment_aggregate_event_listener branch from 09e8736 to 2d80a7d Compare March 4, 2026 16:33
@github-actions github-actions bot removed documentation Improvements or additions to documentation dependencies Pull requests that update a dependency file python Pull requests that update Python code Frontend typescript *.ts *.tsx Python SDK TypeScript SDK labels Mar 4, 2026
@comet-ml comet-ml deleted a comment from github-actions bot Mar 4, 2026
…-aggregates' into thiagohora/OPIK-4383_add_experiment_aggregate_event_listener
@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Backend Tests - Unit Tests

1 309 tests  +54   1 307 ✅ +54   50s ⏱️ +9s
  156 suites +15       2 💤 ± 0 
  156 files   +15       0 ❌ ± 0 

Results for commit 388c1f1. ± Comparison against base commit 6b1fa21.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Backend Tests - Integration Group 6

104 tests  ±0   104 ✅ ±0   2m 22s ⏱️ +3s
 22 suites ±0     0 💤 ±0 
 22 files   ±0     0 ❌ ±0 

Results for commit 388c1f1. ± Comparison against base commit 6b1fa21.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Backend Tests - Integration Group 7

247 tests  ±0   247 ✅ ±0   2m 40s ⏱️ +5s
 25 suites ±0     0 💤 ±0 
 25 files   ±0     0 ❌ ±0 

Results for commit 388c1f1. ± Comparison against base commit 6b1fa21.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Backend Tests - Integration Group 11

218 tests  ±0   216 ✅ ±0   2m 32s ⏱️ -4s
 36 suites ±0     2 💤 ±0 
 36 files   ±0     0 ❌ ±0 

Results for commit 388c1f1. ± Comparison against base commit 6b1fa21.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Backend Tests - Integration Group 12

134 tests  ±0   134 ✅ ±0   2m 51s ⏱️ -14s
 16 suites ±0     0 💤 ±0 
 16 files   ±0     0 ❌ ±0 

Results for commit 388c1f1. ± Comparison against base commit 6b1fa21.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Backend Tests - Integration Group 16

 21 files  ±0   21 suites  ±0   1m 59s ⏱️ -5s
136 tests ±0  136 ✅ ±0  0 💤 ±0  0 ❌ ±0 
114 runs  ±0  114 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 388c1f1. ± Comparison against base commit 6b1fa21.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Backend Tests - Integration Group 15

 29 files  ±0   29 suites  ±0   3m 23s ⏱️ -23s
185 tests ±0  185 ✅ ±0  0 💤 ±0  0 ❌ ±0 
183 runs   - 2  183 ✅  - 2  0 💤 ±0  0 ❌ ±0 

Results for commit 388c1f1. ± Comparison against base commit 6b1fa21.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Backend Tests - Integration Group 8

259 tests  ±0   256 ✅ ±0   4m 23s ⏱️ -21s
 24 suites ±0     3 💤 ±0 
 24 files   ±0     0 ❌ ±0 

Results for commit 388c1f1. ± Comparison against base commit 6b1fa21.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Backend Tests - Integration Group 5

1 114 tests  ±0   1 113 ✅ ±0   5m 19s ⏱️ +18s
    6 suites ±0       1 💤 ±0 
    6 files   ±0       0 ❌ ±0 

Results for commit 388c1f1. ± Comparison against base commit 6b1fa21.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Backend Tests - Integration Group 1

391 tests  ±0   391 ✅ ±0   7m 19s ⏱️ +3s
 21 suites ±0     0 💤 ±0 
 21 files   ±0     0 ❌ ±0 

Results for commit 388c1f1. ± Comparison against base commit 6b1fa21.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Backend Tests - Integration Group 10

232 tests  ±0   230 ✅ ±0   6m 38s ⏱️ -5s
 28 suites ±0     2 💤 ±0 
 28 files   ±0     0 ❌ ±0 

Results for commit 388c1f1. ± Comparison against base commit 6b1fa21.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Backend Tests - Integration Group 9

337 tests  ±0   334 ✅ ±0   8m 26s ⏱️ +28s
 29 suites ±0     3 💤 ±0 
 29 files   ±0     0 ❌ ±0 

Results for commit 388c1f1. ± Comparison against base commit 6b1fa21.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Backend Tests - Integration Group 4

    5 files  ±0      5 suites  ±0   2m 57s ⏱️ +8s
1 346 tests ±0  1 346 ✅ ±0  0 💤 ±0  0 ❌ ±0 
1 259 runs  +2  1 259 ✅ +2  0 💤 ±0  0 ❌ ±0 

Results for commit 388c1f1. ± Comparison against base commit 6b1fa21.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Backend Tests - Integration Group 13

391 tests  ±0   391 ✅ ±0   5m 33s ⏱️ +5s
 17 suites ±0     0 💤 ±0 
 17 files   ±0     0 ❌ ±0 

Results for commit 388c1f1. ± Comparison against base commit 6b1fa21.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Backend Tests - Integration Group 14

173 tests  ±0   173 ✅ ±0   5m 27s ⏱️ +11s
 10 suites ±0     0 💤 ±0 
 10 files   ±0     0 ❌ ±0 

Results for commit 388c1f1. ± Comparison against base commit 6b1fa21.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Backend Tests - Integration Group 2

240 tests  ±0   240 ✅ ±0   13m 18s ⏱️ - 1m 1s
 17 suites ±0     0 💤 ±0 
 17 files   ±0     0 ❌ ±0 

Results for commit 388c1f1. ± Comparison against base commit 6b1fa21.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Backend Tests - Integration Group 3

307 tests  ±0   307 ✅ ±0   9m 50s ⏱️ +16s
 28 suites ±0     0 💤 ±0 
 28 files   ±0     0 ❌ ±0 

Results for commit 388c1f1. ± Comparison against base commit 6b1fa21.

♻️ This comment has been updated with latest results.

Skip delete, cascading operations, and SpansDeleted event when
getSpanIdsForTraces returns an empty set, preserving the original
no-op behaviour and avoiding the Preconditions.checkArgument failure
in SpanDAO.deleteByIds.
Two bugs prevented spans and attachments from being deleted when a trace
was deleted via the event-driven cascade:

1. FeedbackScoreService.deleteByTraceIds/deleteBySpanIds had @nonnull on
   projectId which threw NPE when TracesDeleted.projectId() was null.
   EventInterceptor swallowed the NPE, stopping the entire cascade chain.
   Fix: remove @nonnull since the DAO already handles null safely via
   Optional.ofNullable(projectId).

2. SpanDAO.DELETE_BY_IDS had the wrong column (trace_id) and parameter
   name (span_ids) — the ClickHouse R2DBC driver could not resolve :span_ids
   as a named parameter in the DELETE statement. Fixed by using id IN :ids
   to match the working pattern in TraceDAO.DELETE_BY_ID.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backend java Pull requests that update Java code tests Including test files, or tests related like configuration.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant