[1/2] chipingress: add ErrorCodeFor for partial delivery error classification#2274
Conversation
…y metrics Add batch.ErrorCodeFor to classify send/queue errors into bounded error_code strings.\nExport ErrMessageBufferFull and ErrClientShutdown sentinels.\nHandle synthetic ErrCodeResultsMismatch (-1) explicitly as 'results_mismatch'.
|
👋 pkcll, thanks for creating this pull request! To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team. Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks! |
✅ API Diff Results -
|
There was a problem hiding this comment.
Pull request overview
This PR adds a small error-classification helper to the chip ingress batch client so batch send/queue failures can be mapped to bounded error_code strings for metrics/log enrichment, including explicit handling of the synthetic ErrCodeResultsMismatch publish error code.
Changes:
- Introduces
batch.ErrorCodeFor(err)to map send/queue errors (publish errors, gRPC status codes, context cancellation/timeouts, and internal client sentinels) into bounded strings. - Exports
ErrMessageBufferFullandErrClientShutdownsentinels and updatesQueueMessageto return them instead of allocating new errors. - Adds unit tests covering the new classification behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pkg/chipingress/batch/client.go | Adds ErrorCodeFor, exports sentinels, and updates queue error returns to use them. |
| pkg/chipingress/batch/client_test.go | Adds test coverage for ErrorCodeFor classifications. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if st, ok := status.FromError(err); ok { | ||
| return st.Code().String() | ||
| } |
| if errors.Is(err, ErrMessageBufferFull) { | ||
| return ErrMessageBufferFull.Error() | ||
| } | ||
| if errors.Is(err, ErrClientShutdown) { | ||
| return ErrClientShutdown.Error() | ||
| } |
Updates the root go.mod/go.sum to use the merged main commit of the chipingress submodule.\nThis resolves the dependency validation failure that required chipingress pseudo-versions to exist on main.
Adds
batch.ErrorCodeForto classify batch send/queue errors into boundederror_codestrings, exportsErrMessageBufferFullandErrClientShutdownsentinels, and handles the syntheticErrCodeResultsMismatch(-1) explicitly asresults_mismatch.\n\nThe beholder consumer lives in #2266.