-
Notifications
You must be signed in to change notification settings - Fork 919
GODRIVER-3690 Add ErrorCodesFrom to the mongo package #2241
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
base: master
Are you sure you want to change the base?
GODRIVER-3690 Add ErrorCodesFrom to the mongo package #2241
Conversation
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.
Pull Request Overview
This PR extends the CommandFailedEvent structure to include error codes, addressing GODRIVER-3690. The change enables users to access error codes directly from command failure events without parsing the error themselves.
Key changes:
- Added a
Codesfield toCommandFailedEventto expose error codes - Implemented
errorCodes()helper function to extract codes from driver errors - Added test coverage for the new field
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| event/monitoring.go | Added Codes field to CommandFailedEvent structure |
| x/mongo/driver/operation.go | Populates the new Codes field when publishing failed events; removed blank line |
| x/mongo/driver/errors.go | Implemented errorCodes() function to extract error codes from driver errors |
| mongo/errors.go | Refactored variable declarations to use var() block (style change) |
| internal/integration/clam_prose_test.go | Added test case for CommandFailedEvent.Codes; removed blank line |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
🧪 Performance ResultsCommit SHA: 58198cfThe following benchmark tests for version 692f82f467740700079be35b had statistically significant changes (i.e., |z-score| > 1.96):
For a comprehensive view of all microbenchmark results for this PR's commit, please check out the Evergreen perf task for this patch. |
API Change Report./v2/mongocompatible changesErrorCodesFrom: added |
3b7f589 to
63d4781
Compare
63d4781 to
58198cf
Compare
GODRIVER-3690
Summary
Add an
ErrorCodesFromfunction that can be used to parse server error codes from an arbitrary Go error.Background
Would be convenient to get server status codes without caller taking a dependency on the experimental API. For example, OpenTelemetry needs to include
db.response.status.codefor otelmongo: open-telemetry/opentelemetry-go-contrib#7983 (comment)An alternative to this design would be to put
Codesonevent.CommandFailedEvent. Suggest we forgo this solution for two reasons:event.CommandFailedEvent