Skip to content

refactor(alerts): keep the stream in AlertUtil.getFilteredEvents - #33287

Open
manerow wants to merge 1 commit into
mainfrom
refactor/alertutil-filtered-events-stream
Open

manerow wants to merge 1 commit into
mainfrom
refactor/alertutil-filtered-events-stream

Conversation

@manerow

@manerow manerow commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #32953. Fixes #31331

What this changes

#32953 changed AlertUtil.getFilteredEvents so that it checks each change event on its own: if checking one event throws, only that event is left out. Along the way it replaced the original entrySet().stream().filter(...).collect(toMap(...)) with a HashMap and a for loop. The loop was not needed, and review on the 2.0 backport (#33282) asked for the stream to come back.

This PR restores the stream. The only difference from the code before #32953 is that the filter calls isChangeEventAllowed, which catches failures, instead of checkIfChangeEventIsAllowed, which can throw.

Why behaviour does not change

  • isChangeEventAllowed never throws. It catches the filter's exception, and a separate guard catches anything thrown by the error handler. So the stream can't be cut short, and it keeps the same events the loop kept.
  • Collectors.toMap rejects null values and duplicate keys. The map values are always non-null, and a map's entries can't have duplicate keys. The original code already used toMap.
  • Delivery order is unchanged. Both versions collected into a hash map, so order was already arbitrary.

How it was tested

  • spotless:apply clean.
  • Unit tests green: AlertUtilFilterIsolationTest, AlertsRuleEvaluatorUndeclaredFieldTest, AbstractEventConsumerTest, EventSubscriptionSchedulerTest, AlertUtilTest. The isolation tests cover a batch where one event fails and a batch where the error handler itself also fails.

The same change is applied to the 2.0 backport in #33282, so both branches stay identical.

@manerow
manerow requested a review from a team as a code owner September 14, 2026 18:55
@manerow manerow added safe to test Add this label to run secure Github workflows on PRs backend labels Sep 14, 2026
@manerow manerow self-assigned this Sep 14, 2026
@gitar-bot

gitar-bot Bot commented Sep 14, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

Restores the stream-based approach in AlertUtil.getFilteredEvents to improve code clarity while maintaining the same behavior. The refactored code uses isChangeEventAllowed with exception handling instead of the loop-based implementation, ensuring that filtering failures are caught without short-circuiting the stream. No issues found.

Review coverage

Rules No rules evaluated

Functional validation Not enabled · Set up

Auto-approval Not enabled · Set up

Options

Display: compact → Counting what did not apply, without listing it.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@github-actions

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit 52faa4183d89ce198daf2b4a528e0bc416519f14 in Playwright run 34883752066, attempt 1.

✅ 295 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky

Performance

Blocking targets: ✅ met · Optimization targets: 🟡 in progress

Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting.

🕒 Full workflow signal wall (to summary) 29m 56s

⏱️ Max setup 5m 28s · max shard execution 13m 43s · max shard-job elapsed before upload 16m 52s · reporting 3s

🌐 214.29 requests/attempt · 1.98 app boots/UI scenario · 37.06% common-shard skew

Optimization targets still in progress:

  • Common shard skew was 37.06% (convergence target: at most 15%).
  • Browser traffic was 214.29 requests per attempt (convergence target: fewer than 200).
  • Application boot ratio was 1.98 per UI scenario (625 boots / 316 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard chromium-01 129 0 0 0 0 0
✅ Shard chromium-02 107 0 0 0 0 0
✅ Shard import-export-01 26 0 0 0 0 0
✅ Shard ingestion-01 30 0 0 0 0 0
✅ Shard reindex-01 3 0 0 0 0 0

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

@manerow
manerow added this pull request to the merge queue Sep 15, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-09-15T11:50:22Z)

Blocked the queue: playwright-summary

@ShaileshParmar11
ShaileshParmar11 added this pull request to the merge queue Sep 15, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-09-15T12:49:51Z)

Blocked the queue: integration-tests-postgres-opensearch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

getEntityOrNull catches only EntityNotFoundException, so an undeclared field aborts the whole change-event batch

2 participants