-
Notifications
You must be signed in to change notification settings - Fork 171
[worker] Logs improvements #3397
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
|
Subscribed to pull request
Generated by CodeMention |
58b9ffb to
35c5371
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3397 +/- ##
==========================================
+ Coverage 52.30% 52.43% +0.14%
==========================================
Files 804 803 -1
Lines 33421 33416 -5
Branches 6972 6967 -5
==========================================
+ Hits 17478 17519 +41
- Misses 14555 15815 +1260
+ Partials 1388 82 -1306 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
|
||
| await waitForStreamFlush(); | ||
|
|
||
| expect(outputStream.readableLength).toBe(0); |
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.
would be nice to add a test with a filtered secret
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.
eas-cli/packages/worker/src/__unit__/logger.test.ts
Lines 11 to 41 in 598691b
| it('obfuscates secrets in logs', async () => { | |
| const { logger, outputStream } = await createBuildLoggerWithSecretsFilter([ | |
| { name: 'TEST_SECRET', value: 'secret', type: EnvironmentSecretType.STRING }, | |
| { | |
| name: 'ANOTHER_SECRET_BASE64', | |
| value: 'YW5vdGhlclNlY3JldA==', | |
| type: EnvironmentSecretType.STRING, | |
| }, | |
| ]); | |
| const logs: any[] = []; | |
| const writable = new Writable({ | |
| objectMode: true, | |
| write(chunk: any, _encoding: BufferEncoding, callback: TransformCallback) { | |
| logs.push(chunk); | |
| callback(null, chunk); | |
| }, | |
| }); | |
| outputStream.pipe(writable); | |
| logger.info('this is a secret'); | |
| logger.info(`another secret in base64 is ${Buffer.from('anotherSecret').toString('base64')}`); | |
| await waitForStreamFlush(); | |
| expect(logs.length).toBe(2); | |
| expect(logs[0].msg).toBe('this is a ******'); | |
| expect(logs[1].msg).toBe('another ****** in base64 is ********************'); | |
| }); |
|
⏩ The changelog entry check has been skipped since the "no changelog" label is present. |
Why
For the new logs experience we need to identify every log with a unique ID.
Also, in the new logs experience we're going to be handling logs in plaintext, uncompressed, so size starts to matter.
How
Decorating every log with a unique ID is surprisingly difficult with bunyan. It only runs serializers on the object passed in, I tried adding a
log_idserializerserializers: { log_id: () => uuidv7() }and a non-empty value to build logger, but it was getting serialized in the moment of logger creation.Instead, I'm adding
log_idin theTransformthat also masks secrets. The overall architecture looks like this now:Also removes
service: 'worker'andhostnamefrom logs.servicewas only being used here which I don't think is a thing right now.Test Plan
Added unit test that ensures
TransformaddslogId.