-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
feat(NODE-4687): Add logging to server selection #3946
Conversation
Reference to the failing tests: there are two spec tests with the same description 'server-selection-logging', which cause a MochaError. Anyone know a work around? |
@dariakp I am wondering if this should be changed in the spec itself? |
We shouldn't be duplicating all the unified tests here. I'd update the name of one of the duplicates here in this PR, open a DRIVERS ticket to change the name, and point to this PR as the reference implementation for the change. |
I found a related ticket in the logging epic filed recently about potentially removing Load Balancer mode in server selection logging, this would also mean removing one of the duplicate test descriptions. I messaged in the drivers-1204-logging channel for more information: |
a5da0d6
to
82a5e60
Compare
82a5e60
to
fc5bca0
Compare
src/mongo_logger.ts
Outdated
@@ -369,11 +383,17 @@ export function stringifyWithMaxLen( | |||
maxDocumentLength: number, | |||
options: EJSONOptions = {} | |||
): string { | |||
const ejson = EJSON.stringify(value, options); | |||
maxDocumentLength = 20; |
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.
Why are we overwriting maxDocumentLength
here? This would make us non-compliant with the spec that states that our default maxDocumentLength
should be 1000 (characters in our case) and also override the value passed in to defaultLogTransform
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.
This was part of debugging and I forgot to remove it before pushing. It's removed now.
log: Record<string, any>, | ||
event: ConnectionPoolMonitoringEvent | ServerOpeningEvent | ServerClosedEvent | ||
) { | ||
function attachConnectionFields(log: Record<string, any>, event: 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.
Why did we broaden the type of the event
parameter?
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.
We use this function for all SDAM Events, too. We used to use it for server selection events as well before serverHost
and serverPort
were defined directly on the loggable server selection event classes.
src/operations/execute_operation.ts
Outdated
@@ -251,7 +254,10 @@ async function retryOperation< | |||
} | |||
|
|||
// select a new server, and attempt to retry the operation | |||
const server = await topology.selectServerAsync(selector, { session }); | |||
const server = await topology.selectServerAsync(selector, { | |||
session: session, |
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.
session: session, | |
session, |
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.
Didn't catch that, should be changed now.
4617695
to
5322cf6
Compare
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.
There are failures in the unit tests now around max staleness. These tests are using the server selection test helper here so I suspect the changes in this PR are directly related.
Ah, I see, I'll be more mindful of running unit tests before I push in the future. |
Description
Add logging to server selection.
What is changing?
When logging is enabled at the debug level, users will be able to see "server selection started, succeeded and failed events". When logging is enabled at the info level, users will be able to see "waiting for suitable server events".
Is there new documentation needed for these changes?
Not until logging is released (NODE-5672)
What is the motivation for this change?
To help users see their server selection events, depending on their logging level enabled.
Double check the following
npm run check:lint
scripttype(NODE-xxxx)[!]: description
feat(NODE-1234)!: rewriting everything in coffeescript