Skip to content

perf(notification): make event delivery status loading opt-in - #5532

Merged
chrisgacsal merged 1 commit into
mainfrom
perf/notification-delivery-status-expand
Nov 16, 2026
Merged

chrisgacsal merged 1 commit into
mainfrom
perf/notification-delivery-status-expand

Conversation

@chrisgacsal

@chrisgacsal chrisgacsal commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Overview

Event reads eagerly loaded delivery statuses and their attempt histories even when the caller only needed the Event. The entitlement balance and reset workers paid for that extra query on every matching lookup.

Make delivery status loading opt-in on ListEvents and GetEvent. Both workers keep their existing ListEvents filters and pagination. The V1 and V3 HTTP handlers, reconciler, and resend path explicitly request delivery statuses.

Notes for reviewer

  • An omitted or empty EventExpand skips loading delivery statuses. Filtering by delivery state still works independently of expansion.
  • Pagination continues to compute TotalCount. This change can ship independently of the delivery status index in perf(notification): index delivery status lookups by event ID #5510.
  • Tests cover both workers’ lookup inputs and all three expansion cases for get and list. The eight affected packages passed with -race, including PostgreSQL-backed tests. Scoped lint reported zero issues.

Summary by CodeRabbit

  • New Features
    • Event retrieval and listing now support optionally including delivery-status details.
  • Bug Fixes
    • Notification event views and processing paths now request delivery-status details when needed, while pending-status filtering continues to work without expanding those details.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; current callers retain the delivery data they need.

Summary

Makes delivery-status loading opt-in for ListEvents and GetEvent.

  • Event reads load delivery details only when callers ask.

No actionable issues found. Tests were not run during this review.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[ListEvents or GetEvent] --> B[Load event, rule, and active channels]
  B --> C{Expand.DeliveryStatus?}
  C -->|Yes| D[Load delivery statuses and attempts]
  C -->|No| E[Skip delivery statuses]
  D --> F[Return event]
  E --> F
Loading

Reviews (1) · Last reviewed commit: "perf(notification): make event delivery ..." · Reviewed by Greptile

@chrisgacsal
chrisgacsal requested a review from a team as a code owner November 16, 2026 09:28
@chrisgacsal chrisgacsal added the release-note/bug-fix Release note: Bug Fixes label Nov 16, 2026
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Event reads now support optional delivery-status expansion. The adapter loads delivery statuses only when requested, and callers that use them request the expansion. The changes also add tests for threshold-handler event queries.

Changes: Event delivery-status expansion

Layer / File(s) Summary
Expansion contract and adapter query
openmeter/notification/event.go, openmeter/notification/adapter/event.go, openmeter/notification/adapter/*_test.go
List and get inputs add an expansion option. The adapter conditionally loads delivery statuses, and tests cover requested and omitted expansion.
Expansion requests at event callers
api/v3/handlers/notification/events/*, openmeter/notification/eventhandler/*, openmeter/notification/httpdriver/event.go, openmeter/notification/service/event.go
The API handlers, HTTP driver, reconciliation, and resend lookup request expanded delivery statuses. The webhook test also fetches the event with expansion enabled.

Entitlement threshold event-query tests

Layer / File(s) Summary
Threshold event-query assertions
openmeter/notification/consumer/entitlementbalancethreshold_test.go
New tests check the event-list inputs used by the threshold and reset handlers.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Suggested reviewers: borosr, gergely-kurucz-konghq, galexihu

Merge Risk: Minimal · up to d88bc

This change makes delivery-status loading opt-in for event reads, and the callers that need the data now request it. No concrete defect was found, so the change looks safe to merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: delivery status loading in notification event queries becomes opt-in through an expansion option. The raw summary confirms this in ListEvents, GetEvent, and the adapte…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: delivery status loading in notification event queries becomes opt-in through an expansion option. The raw summary confirms this in ListEvents, GetEvent, and the adapter query helper. The perf() prefix is a conventional commit type and fits the performance intent in the objectives. The title is concise and specific.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 38a1f06 and d88bc31.

Files selected for processing: 11

  • api/v3/handlers/notification/events/get.go
  • api/v3/handlers/notification/events/list.go
  • openmeter/notification/adapter/deliverystatus_test.go
  • openmeter/notification/adapter/event.go
  • openmeter/notification/adapter/event_test.go
  • openmeter/notification/consumer/entitlementbalancethreshold_test.go
  • openmeter/notification/event.go
  • openmeter/notification/eventhandler/reconcile.go
  • openmeter/notification/eventhandler/webhook_test.go
  • openmeter/notification/httpdriver/event.go
  • openmeter/notification/service/event.go

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

@chrisgacsal
chrisgacsal merged commit c987793 into main Nov 16, 2026
33 of 35 checks passed
@chrisgacsal
chrisgacsal deleted the perf/notification-delivery-status-expand branch November 16, 2026 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/bug-fix Release note: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants