-
Notifications
You must be signed in to change notification settings - Fork 229
fix(logger): replace PassThrough with Writable for log handling COMPASS-9736 #7222
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
Merged
+124
−13
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
d952737
fix(logger): replace PassThrough with Writable for log handling CLOUD…
nbbeeken 075a733
fix(logger): replace PassThrough with Writable for log handling CLOUD…
nbbeeken 533f97a
test: synchronous log call
nbbeeken f039277
add events
syn-zhu 85d9edd
Merge branch 'CLOUDP-332732' of https://github.com/mongodb-js/compass…
syn-zhu 05dd5e5
add more logs
syn-zhu 43838ce
remoce fields
syn-zhu 8ea0ba3
Merge branch 'main' into CLOUDP-332732
syn-zhu 2e3cb29
fix test
syn-zhu f24620d
fix logging test
syn-zhu bc4b214
remove flags
syn-zhu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import type { Logger } from '@mongodb-js/compass-logging/provider'; | ||
import { MongoLogWriter } from 'mongodb-log-writer/mongo-log-writer'; | ||
import { PassThrough } from 'stream'; | ||
import type { Writable } from 'stream'; | ||
import { mongoLogId } from '@mongodb-js/compass-logging/provider'; | ||
import { useRef } from 'react'; | ||
|
||
|
@@ -62,13 +62,17 @@ export class CompassWebLogger implements Logger { | |
}; | ||
} | ||
) { | ||
const passThrough = new PassThrough({ objectMode: true }); | ||
this.log = new MongoLogWriter('', '', passThrough).bindComponent( | ||
this.component | ||
); | ||
passThrough.on('data', (line) => { | ||
callbackRef.current.onLog?.(JSON.parse(line)); | ||
}); | ||
const target = { | ||
write(line: string, callback: () => void) { | ||
callbackRef.current.onLog?.(JSON.parse(line)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to update the test ensure it's happening synchronously? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added one! |
||
callback(); | ||
nbbeeken marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
end(callback: () => void) { | ||
callback(); | ||
nbbeeken marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
} as Writable; | ||
nbbeeken marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
this.log = new MongoLogWriter('', '', target).bindComponent(this.component); | ||
|
||
this.debug = createCompassWebDebugger(this.component, this.callbackRef); | ||
} | ||
|
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
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
Oops, something went wrong.
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.
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.
@syn-zhu On line 1583, there is log
1_001_000_004
that carries the same info, is there a significance to this logs position over that one?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.
related to my response to your next comment: Our purpose for introducing these logs was to facilitate connection latency tracking with Sentry. Given that, I wanted to reduce the surface area to connection attempts that would actually be meaningful.