feat: add MongoDB driver handshake metadata#2134
Open
alexbevi wants to merge 1 commit into
Open
Conversation
Exposes a `client_options()` helper that returns `ClientOptions` pre-configured with `DriverInfo` so MongoDB server-side telemetry can identify traffic from Rig applications.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
rig_mongodb::client_options()helper that returnsClientOptionspre-configured with MongoDBDriverInfo, allowing the MongoDB server to identify traffic from Rig applications in server-side telemetry, Atlas dashboards, anddb.currentOp().What changes
rig-mongodbreceives a pre-builtmongodb::Collectionfrom callers, so it has no hook point to inject metadata at construction time. The Rust driver has no post-construction API equivalent, so the right approach is a public factory helper:The helper sets
driver_infowith name"rig-mongodb"and the crate's version (read at compile time viaenv!("CARGO_PKG_VERSION")). The existing example inexamples/vector_search_mongodb.rsis updated to use the helper.How it appears in the logs
The handshake document visible in
mongoddiagnostic logs anddb.currentOp()will include adriverfield alongside the basemongodbRust driver info:{ "driver": { "name": "mongodb|rig-mongodb", "version": "3.7.0|0.40.0" } }See the MongoDB handshake specification for details.
Testing
Added two unit tests in
src/lib.rs:client_options_sets_driver_info— confirmsdriver_info.nameequals"rig-mongodb"and version is presentdriver_name_is_not_empty— guards against accidental empty-string nameChecklist