-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[scout] improve logs readability by using unique logger context per playwright worker #213218
base: main
Are you sure you want to change the base?
Conversation
const corePageObjects = createCorePageObjects(page); | ||
log.serviceLoaded(`pageObjects:${scoutSpace.id}`); |
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 believe it is redundant: logger context helps to understand the space we use, there is a 1 to 1 match.
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.
Sounds good about the test space ID being redundant.
A possible improvement for the future (possibly out of scope for this PR): instead of logging just pageObjects
(the service name), we could log pageObjects loaded
or perhaps pageObjects service loaded
to make it clear the service was loaded (successfully). What do you think?
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 was thinking about it too, how about having it this way (actually it was in PoC like that):
/**
* Used to log when a service/fixture is loaded
* @param name unique name of the service
*/
public serviceLoaded(name: string) {
this.debug(`[${name}] loaded`);
}
/**
* Used to log a message for a service/fixture
*/
public serviceMessage(name: string, message) {
this.debug(`[${name}] ${name}`);
}
output
debg [scout-worker-2] [scoutPage] loaded
debg [scout-worker-2] [pageObjects] loaded
debg [scout-worker-2] [scoutPage] just a random message from service
alternatively
debg [scout-worker-2] [service] 'scoutPage' loaded
debg [scout-worker-2] [service] 'pageObjects' loaded
debg [scout-worker-2] [service] [pageObjects] just a random message from service
but maybe we don't need that [service]
context assuming we know that it is coming from playwright worker?
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.
locally run
[chromium] › saved_searches.spec.ts:66:14 › Discover app - saved searches › should customize time range on dashboards @ess @svlSearch @svlOblt
debg [scout-worker-2] [logger] loaded
info [scout-worker-2] [config] Reading test servers confiuration from file: /Users/dmle/github/kibana/.scout/servers/local.json
debg [scout-worker-2] [config] loaded
debg [scout-worker-2] [kbnClient] loaded
debg [scout-worker-2] Requesting url (redacted): [http://localhost:5620/api/spaces/space]
[chromium] › error_handling.spec.ts:30:12 › Discover app - errors › should render invalid scripted field error @ess
debg [scout-worker-1] [logger] loaded
info [scout-worker-1] [config] Reading test servers confiuration from file: /Users/dmle/github/kibana/.scout/servers/local.json
debg [scout-worker-1] [config] loaded
debg [scout-worker-1] [kbnClient] loaded
debg [scout-worker-1] Requesting url (redacted): [http://localhost:5620/api/spaces/space]
@@ -33,7 +33,7 @@ export const scoutPageParallelFixture = base.extend< | |||
extendedPage.gotoApp = (appName: string, pathOptions?: PathOptions) => | |||
page.goto(kbnUrl.app(appName, { space: scoutSpace.id, pathOptions })); | |||
|
|||
log.serviceLoaded(`scoutPage:${scoutSpace.id}`); |
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.
same here, scout-worker-N
logger context is good enough
@@ -19,46 +19,42 @@ export const scoutSpaceParallelFixture = coreWorkerFixtures.extend< | |||
>({ | |||
scoutSpace: [ | |||
async ({ log, kbnClient }, use, workerInfo) => { | |||
const spaceId = `test-space-${workerInfo.workerIndex}`; | |||
const spaceId = `test-space-${workerInfo.parallelIndex + 1}`; |
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.
workerIndex
vs parallelIndex
:
Playwright created new worker after failure, workerIndex
will be increased. Since we delete Kibana space on fixture tear down, we can and should use persistent index - parallelIndex
https://playwright.dev/docs/api/class-workerinfo#worker-info-parallel-index
// will create new copies of saved objects with unique ids | ||
createNewCopies: true, | ||
}); | ||
return measurePerformanceAsync(log, `${spaceId}: 'savedObjects.load'`, async () => { |
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.
simplifying message, as we know the worker index now
>({ | ||
log: [ | ||
({}, use) => { | ||
use(getLogger('scout')); |
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.
when tests are run sequentially we will keep using "scout" context
>({ | ||
log: [ | ||
({}, use, workerInfo) => { | ||
const loggerContext = `scout-worker-${workerInfo.workerIndex + 1}`; |
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.
Should we use the parallelIndex
instead of the workerIndex
here, too? Perhaps (and most likely) it makes no difference, but I wonder what you think.
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 should ;) thanks for paying attention, I assumed I did it right.
); | ||
return measurePerformanceAsync(log, `${spaceId}: 'uiSettings.setDefaultTime'`, async () => { | ||
const utcFrom = isValidUTCDate(from) ? from : formatTime(from); | ||
const untcTo = isValidUTCDate(to) ? to : formatTime(to); |
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.
A typo here, most likely: untcTo
should be utcTo
.
It's nice to now see the worker number next to the log, it seems to be working well with 1, 2, and 3 parallel workers: ✅ 1 WorkerRunning 9 tests using 1 worker
[chromium] › error_handling.spec.ts:30:12 › Discover app - errors › should render invalid scripted field error @ess
debg [scout-worker-1] [service] logger
info [scout-worker-1] [config] Reading test servers configuration from file: /Users/cesaredecal/dev/kibana/.scout/servers/local.json
debg [scout-worker-1] [service] config
debg [scout-worker-1] [service] kbnClient
debg [scout-worker-1] Requesting url (redacted): [http://localhost:5620/api/spaces/space]
debg [scout-worker-1] Requesting url (redacted): [http://localhost:5620/api/spaces/space]
debg [scout-worker-1] Requesting url (redacted): [http://localhost:5620/api/spaces/space]
... ✅ 2 WorkersRunning 9 tests using 2 workers
[chromium] › error_handling.spec.ts:30:12 › Discover app - errors › should render invalid scripted field error @ess
debg [scout-worker-1] [service] logger
[chromium] › saved_searches.spec.ts:66:14 › Discover app - saved searches › should customize time range on dashboards @ess @svlSearch @svlOblt
debg [scout-worker-2] [service] logger
info [scout-worker-1] [config] Reading test servers configuration from file: /Users/cesaredecal/dev/kibana/.scout/servers/local.json
debg [scout-worker-1] [service] config
info [scout-worker-2] [config] Reading test servers configuration from file: /Users/cesaredecal/dev/kibana/.scout/servers/local.json
debg [scout-worker-2] [service] config
debg [scout-worker-1] [service] kbnClient
debg [scout-worker-2] [service] kbnClient
debg [scout-worker-1] Requesting url (redacted): [http://localhost:5620/api/spaces/space]
debg [scout-worker-2] Requesting url (redacted): [http://localhost:5620/api/spaces/space]
debg [scout-worker-1] test-space-1: 'spaces.create' took 816.28ms
debg [scout-worker-1] [service] new Kibana space test-space-1 created
... ✅ 3 WorkersRunning 9 tests using 3 workers
[chromium] › saved_searches.spec.ts:66:14 › Discover app - saved searches › should customize time range on dashboards @ess @svlSearch @svlOblt
debg [scout-worker-2] [service] logger
info [scout-worker-2] [config] Reading test servers confiuration from file: /Users/cesaredecal/dev/kibana/.scout/servers/local.json
debg [scout-worker-2] [service] config
debg [scout-worker-2] [service] kbnClient
[chromium] › error_handling.spec.ts:30:12 › Discover app - errors › should render invalid scripted field error @ess
debg [scout-worker-1] [service] logger
info [scout-worker-1] [config] Reading test servers confiuration from file: /Users/cesaredecal/dev/kibana/.scout/servers/local.json
debg [scout-worker-1] [service] config
debg [scout-worker-1] [service] kbnClient
[chromium] › saved_searches.spec.ts:66:14 › Discover app - saved searches › should customize time range on dashboards @ess @svlSearch @svlOblt
debg [scout-worker-2] Requesting url (redacted): [http://localhost:5620/api/spaces/space]
[chromium] › error_handling.spec.ts:30:12 › Discover app - errors › should render invalid scripted field error @ess
debg [scout-worker-1] Requesting url (redacted): [http://localhost:5620/api/spaces/space]
... |
…na into scout/fix-logger-context
@@ -130,11 +118,12 @@ export const scoutSpaceParallelFixture = coreWorkerFixtures.extend< | |||
setDefaultTime, | |||
}; | |||
|
|||
log.serviceLoaded(`scoutSpace:${spaceId}`); | |||
log.serviceLoaded(`new Kibana space ${spaceId} created`); |
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.
Now that we updated the serviceLoaded
function to print loaded
at the end of the string (thanks for making the change), this may not make much sense anymore (the log would end with created loaded
). Perhaps we want to use log.debug
here instead of log.serviceLoaded
?
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.
you got me again :) as it is important to know space name to better understand error logs / screenshot, we can use
serviceMessage('scoutSpace', `new Kibana space '${spaceId}' created`)
to see
debg [scout-worker-1] [scoutSpace] new Kibana space 'test-space-1' created
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.
Neat! Nit, non-blocking at all: perhaps new
can be New
(uppercase N
).
💔 Build Failed
Failed CI StepsMetrics [docs]Public APIs missing comments
Unknown metric groupsAPI count
History
cc @dmlemeshko |
Summary
Part of #203591
Our current logs are confusing as it is unclear to which worker message is related. E.g.
it is not clear if the messages are coming from the same worker or 2 different ones.
Before
After:
Note: single thread run will still log under
scout
context, let me know if it is preferable to have it similar to parallel run, e.g.[scout-worker] [service] scoutPage
How to verify:
node scripts/scout.js start-server --stateful
npx playwright test --config x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel.playwright.config.ts