feat(alerts): let a consumer record its own deliveries - #33127
Conversation
…e activity domain scope Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
|
manerow
left a comment
There was a problem hiding this comment.
Looks good to me.
What I checked:
recordDeliveryandrecordFailureonly affect a consumer that calls them, and no existing consumer does, so the commit flag stays false on every path they take today.- Committing when the metrics moved, not only when the offset moved, is what makes a self-delivering consumer's counters reach the subscription at all, and the gap-state branch still only runs when no commit happened.
- A failure row written with no change event is accepted by
consumers_dlq, whose generatedNOT NULLcolumn reads the top leveltimestampthatrecordFailuresets, and the row is keyed per subscription so repeated failures replace rather than accumulate. extractTimestampwas the one reader that assumed a change event is always present, and it now falls back to the failure's own timestamp.
One note on sequencing: the Collate side (collate#6141) doesn't call these hooks yet, so its alert still reports zero events sent. Worth wiring up there once this merges, otherwise the gap this PR opens stays unused.



Problem
A consumer that doesn't poll change events can't report what it delivered.
AbstractEventConsumerupdatesAlertMetricsonly on its own poll-and-publish path, and commits only when the offset moved. A subclass that computes its own work has neither, so its alert reports zero events sent on the subscription status and diagnostics endpoints no matter how much it actually delivered.What this adds
protected recordDelivery(int successCount, int failedCount)so a subclass can report what it sent.finallybody moves intopersistTick, now that there are two reasons to commit. Gap state still persists only when no commit happened.Existing consumers are unaffected: nothing calls
recordDelivery, so the new flag is false on every path they take.Tests
3 new in
AbstractEventConsumerTest, 33 pass in the class. Each new test was checked to fail without the fix.Used by https://github.com/open-metadata/openmetadata-collate/pull/6141
🤖 Generated with Claude Code