-
Notifications
You must be signed in to change notification settings - Fork 161
feat(mongodb): Add MongoDB client handshake metadata #625
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: main
Are you sure you want to change the base?
Conversation
mongoOptions.driverInfo = { | ||
name: "unstorage", | ||
}; | ||
const mongoClient = new MongoClient(opts.connectionString, mongoOptions); |
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 think we should instead support generic mongoOptions
as a driver option so you can set it to { driverInfo: { name: "..." } }
based on your needs
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 agree. we could default if it helps:
// in the top of the file
const defaultMongoOptions: MongoClientOptions = {
driverInfo: {
name: "unstorage"
}
};
// here (where i'm commenting in this PR)
const mongoOptions: MongoClientOptions = {
...defaultMongoOptions, // don't bother deep-merging, people can override `driverInfo` as a whole
...opts.clientOptions
};
then update the MongoDbOptions
to have:
clientOptions?: MongoClientOptions;
and either way, we should strongly type this instead of any
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.
Great suggestions! I've worked these into the PR
Co-authored-by: James Garbutt <[email protected]>
Looks good to me 👍 @pi0 I'll leave you to merge once you've had time to read through |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #625 +/- ##
==========================================
- Coverage 59.99% 59.90% -0.10%
==========================================
Files 42 42
Lines 3657 3736 +79
Branches 590 600 +10
==========================================
+ Hits 2194 2238 +44
- Misses 1460 1495 +35
Partials 3 3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
The PR addresses #626 by incorporating MongoDB's wrapping client library specification for the connection handshake to allow library details to be included in the metadata written to
mongos
ormongod
logs.For example, this change would allow server-side logs such as the following:
For anyone hosting clusters with connections coming from different applications this can help differentiate connections and facilitate log analysis.