-
Notifications
You must be signed in to change notification settings - Fork 145
refactor: improve event reconcile #3602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughWalkthroughThis PR modifies notification event handling by updating an error message format in reconcile.go and restructuring the control flow and error handling logic in webhook.go's reconcileWebhookEvent function to prioritize not-found recovery and simplify downstream state processing. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
openmeter/notification/eventhandler/webhook.go (1)
221-227: Let’s merge the webhook annotations here tooSince the
sendingbranch already mergesstatus.Annotationswithmsg.Annotations, doing the same in this pending-to-sending handoff keeps provider metadata (like delivery IDs) from getting dropped. Easy win for parity:input = ¬ification.UpdateEventDeliveryStatusInput{ NamespacedID: status.NamespacedID, State: state, - Annotations: status.Annotations, + Annotations: status.Annotations.Merge(msg.Annotations), NextAttempt: nextAttempt, Attempts: attempts, }
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
openmeter/notification/eventhandler/reconcile.go(1 hunks)openmeter/notification/eventhandler/webhook.go(3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.go
⚙️ CodeRabbit configuration file
**/*.go: In general when reviewing the Golang code make readability and maintainability a priority, even potentially suggest restructuring the code to improve them.Performance should be a priority in critical code paths. Anything related to event ingestion, message processing, database operations (regardless of database) should be vetted for potential performance bottlenecks.
Files:
openmeter/notification/eventhandler/reconcile.goopenmeter/notification/eventhandler/webhook.go
🧠 Learnings (2)
📚 Learning: 2025-11-07T12:29:09.087Z
Learnt from: chrisgacsal
Repo: openmeterio/openmeter PR: 3581
File: openmeter/notification/eventhandler/webhook.go:391-396
Timestamp: 2025-11-07T12:29:09.087Z
Learning: In the OpenMeter notification system (specifically in openmeter/notification/eventhandler/webhook.go), webhook channels are equivalent to notification rules. When sending webhook messages, the rule ID (event.Rule.ID) should be used as the channel identifier in the Channels field of SendMessageInput.
Applied to files:
openmeter/notification/eventhandler/reconcile.goopenmeter/notification/eventhandler/webhook.go
📚 Learning: 2025-11-07T11:28:40.430Z
Learnt from: chrisgacsal
Repo: openmeterio/openmeter PR: 3581
File: openmeter/notification/webhook/svix/webhook.go:253-257
Timestamp: 2025-11-07T11:28:40.430Z
Learning: In the openmeter notification system (specifically in openmeter/notification/webhook/svix/webhook.go), event type filtering for webhooks is not allowed or supported. Only channel-based filtering is used.
Applied to files:
openmeter/notification/eventhandler/webhook.go
🧬 Code graph analysis (1)
openmeter/notification/eventhandler/webhook.go (4)
openmeter/notification/webhook/errors.go (1)
IsNotFoundError(69-71)openmeter/notification/deliverystatus.go (2)
EventDeliveryStatusStateSending(16-16)UpdateEventDeliveryStatusInput(175-188)pkg/models/id.go (1)
NamespacedID(7-10)pkg/models/annotation.go (1)
Annotations(3-3)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
- GitHub Check: Analyze (go)
- GitHub Check: Artifacts / Benthos Collector Container image
- GitHub Check: Artifacts / Container image
- GitHub Check: Migration Checks
- GitHub Check: Test
- GitHub Check: Code Generators
- GitHub Check: Lint
- GitHub Check: Build
- GitHub Check: Repository Scan
🔇 Additional comments (1)
openmeter/notification/eventhandler/reconcile.go (1)
117-118: Logging key alignment looks goodLove the tweak to log under
notification.event.id—makes the logs line up with the span attrs without any surprises.
Overview
Improve event reconciliation by removing unnecessary branching in reconcile logic.
Summary by CodeRabbit