notify: add receiver and integration as structured log fields on failures - #5401
notify: add receiver and integration as structured log fields on failures#5401locker95 wants to merge 1 commit into
Conversation
…ures When notification delivery fails, the dispatcher error log only exposed receiver/integration inside the free-text err string. Annotate RetryStage failures with ErrorWithIntegration and attach receiver/integration as structured fields on the dispatch failure log so operators can group by them in log aggregators without regex-parsing err. Fixes prometheus#5396 Signed-off-by: Dean Chen <862469039@qq.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughNotification retry failures now include receiver and integration metadata through a new wrapped error type. Retry termination paths produce this error, and aggregation-group dispatch logging extracts the integration field for structured logs. Tests validate metadata for unrecoverable and canceled retries. ChangesNotification failure context
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant NotificationAttempt
participant RetryStage
participant DispatcherLogger
NotificationAttempt->>RetryStage: return notification error
RetryStage->>RetryStage: wrap receiver and integration metadata
RetryStage->>DispatcherLogger: return ErrorWithIntegration
DispatcherLogger->>DispatcherLogger: add receiver and integration fields
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
Pull Request Checklist
Please check all the applicable boxes.
Which user-facing changes does this PR introduce?
Summary
When a notification send fails, the dispatcher logs
Notify for alerts failedwith onlyaggrGroup,num_alerts, anderras structured fields. The receiver name and integration (e.g.slack[0]) are present only inside the free-texterrstring, which makes log aggregation (Loki/ELK) brittle.Changes
notify.ErrorWithIntegrationto annotate RetryStage failures withreceiverandintegrationreceiver(from the aggregation group) andintegration(when available viaerrors.As) as structured fields on the dispatch failure logChannel is intentionally out of scope here: it is integration-specific and already appears in some integration error messages (e.g. Slack). Receiver/integration alone cover the main operator need from #5396.