-
Notifications
You must be signed in to change notification settings - Fork 918
GODRIVER-3544, GODRIVER-3653 Allow Client to Send Client Metadata On-Demand #2197
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
GODRIVER-3544, GODRIVER-3653 Allow Client to Send Client Metadata On-Demand #2197
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 mongo.Client
API to support appending client metadata on-demand for handshake requests. The implementation allows drivers to dynamically update metadata information (name, version, platform) that is sent to servers during connection establishment.
- Replaces static driver info configuration with atomic pointer-based dynamic metadata management
- Adds
AppendDriverInfo
method toClient
for runtime metadata updates - Refactors topology configuration to use functional options pattern with atomic driver info handling
Reviewed Changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
mongo/client.go | Adds AppendDriverInfo method and atomic driver info management to Client |
x/mongo/driver/topology/topology_options.go | Refactors config creation with functional options and atomic driver info |
x/mongo/driver/topology/server_options.go | Replaces individual driver info fields with atomic pointer |
x/mongo/driver/topology/server.go | Updates connection creation to use atomic driver info |
internal/integration/handshake_test.go | Comprehensive test coverage for dynamic metadata appending |
internal/integration/unified/operation.go | Adds appendMetadata operation support |
internal/integration/unified/client_operation_execution.go | Implements unified test operation execution |
internal/test/client_metadata.go | Test utility for encoding client metadata |
internal/integration/mtest/proxy_*.go | Enhanced proxy message capture for testing |
internal/handshake/handshake.go | Utility for parsing client metadata from wire messages |
internal/assert/assertbsoncore/assertions_bsoncore.go | Assertion helpers for comparing client metadata |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
if s.cfg.driverInfo != nil { | ||
driverInfo := s.cfg.driverInfo.Load() | ||
if driverInfo != nil { | ||
handshaker = handshaker.OuterLibraryName(driverInfo.Name).OuterLibraryVersion(driverInfo.Version). | ||
OuterLibraryPlatform(driverInfo.Platform) | ||
} | ||
} |
Copilot
AI
Sep 12, 2025
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.
[nitpick] The nested nil checks for s.cfg.driverInfo
and driverInfo.Load()
could be simplified using a helper function or by consolidating the logic, improving code readability.
Copilot uses AI. Check for mistakes.
🧪 Performance ResultsCommit SHA: 11797dcThe following benchmark tests for version 68f1ad4b2b4b620007210534 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 changes(*Client).AppendDriverInfo: added ./v2/x/mongo/driver/topologyincompatible changesNewConfigFromOptionsWithAuthenticator: removed compatible changesAuthConfigOption: added |
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.
Looks good! 👍
assert.True(mt, initialClientMetadata.IsHandshake(), "expected first message to be a handshake") | ||
|
||
// Wait 5ms for the connection to become idle. | ||
time.Sleep(20 * time.Millisecond) |
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.
time.Sleep(20 * time.Millisecond) | |
time.Sleep(5 * time.Millisecond) |
Is 5ms enough here? Otherwise, we'd better to match the comment to the code. The following cases also have the mismatches.
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.
I'll check if the tests are reliable with 5ms sleeps. If they are, I'll set them all to 5ms.
One of the tests had a 20ms sleep set, and I wanted to make them consistent so I set them all to 20ms. However, I don't think the sleep duration was the main source of test failures.
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.
Updated all to 5ms and the tests seem to pass consistently.
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.
LGTM, just with some nitpicky comments.
8b483fd
GODRIVER-3544, GODRIVER-3653
Summary
Extend the
mongo.Client
stable API to allow appending handshake client metadata on demand.Background & Motivation
NA