Skip to content

[scout] support log level override#228841

Merged
dmlemeshko merged 9 commits intoelastic:mainfrom
dmlemeshko:scout/support-logger-level-override
Jul 22, 2025
Merged

[scout] support log level override#228841
dmlemeshko merged 9 commits intoelastic:mainfrom
dmlemeshko:scout/support-logger-level-override

Conversation

@dmlemeshko
Copy link
Contributor

@dmlemeshko dmlemeshko commented Jul 21, 2025

Summary

  • default log level for Playwright fixtures is info , afaik default for FTR and other scripts (but for now to better understand performance issues we pass debug through node scripts/scout, to be reverted for GA)
  • node scripts/scout will propagate log level from cli flag (e.g. --debug) with SCOUT_LOG_LEVEL env variable to playwright exec command
  • since some Team may not use scripts/scout command, they can set LOG_LEVEL variable to override to whatever level is needed
    if both LOG_LEVEL and SCOUT_LOG_LEVEL are set, the later has priority (important for us, shouldn't block others)

Playwright Integration:

  • Replaced the use of getLogger with the updated ScoutLogger call in Playwright worker fixtures, enabling log level configuration via environment variables.
  • Modified the Playwright test runner to propagate the log level to the test environment using the SCOUT_LOG_LEVEL variable.

@dmlemeshko dmlemeshko added the ci:scout-ui-tests Run Scout UI tests label Jul 21, 2025
@dmlemeshko dmlemeshko marked this pull request as ready for review July 22, 2025 10:02
@dmlemeshko dmlemeshko requested a review from a team as a code owner July 22, 2025 10:02
@dmlemeshko dmlemeshko added v9.1.0 v8.19.0 v9.2.0 release_note:skip Skip the PR/issue when compiling release notes backport:version Backport to applied version labels labels Jul 22, 2025
Comment on lines +42 to +43
export async function ingestSynthtraceDataHook(config: FullConfig, data: SynthtraceIngestionData) {
const log = getLogger();
const log = new ScoutLogger('scout: global hook', getScoutLogLevel());
Copy link
Contributor Author

@dmlemeshko dmlemeshko Jul 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These functions are for parallel test run, that requires data ingestion to be done in advance.

export function getLogger(workerContext: string = 'scout'): ScoutLogger {
if (!loggerInstances.has(workerContext)) {
loggerInstances.set(workerContext, new ScoutLogger(workerContext));
function resolveLogLevel(envValue: string | undefined): LogLevel | undefined {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any chance we can move (the bulk of) this into new ToolingLog()?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we'd end up with something like new ScoutLogger(loggerContext, process.env.SCOUT_PW_LOG_LEVEL) and then in the ToolingLog constructor we default to { level: process.env.LOG_LEVEL || 'info' } ?

Copy link
Contributor Author

@dmlemeshko dmlemeshko Jul 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed in 072146f , I added comment about priority and changed variable name to SCOUT_LOG_LEVEL because it has zero connection with the playwright internal logging (only our custom fixtures/hooks call it). cc @dolaru @dgieselaar

@dmlemeshko dmlemeshko requested review from dgieselaar and dolaru July 22, 2025 12:38
Copy link
Contributor

@dolaru dolaru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍🏽

Just one nit in one of the code comments.

…/worker/core_fixtures.ts

Co-authored-by: David Olaru <dolaru@vaevixen.com>
@dmlemeshko dmlemeshko self-assigned this Jul 22, 2025
@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/scout 125 123 -2
@kbn/scout-oblt 76 74 -2
@kbn/scout-security 67 65 -2
total -6
Unknown metric groups

API count

id before after diff
@kbn/scout 450 451 +1
@kbn/scout-oblt 370 371 +1
@kbn/scout-security 360 361 +1
total +3

History

cc @dmlemeshko

});
// Temporarily use `debug` log level for Playwright tests to better understand performance issues;
// We are going to change it to `info` in the future. This change doesn't affect Test Servers logging.
const logsLevel = pickLevelFromFlags(globalFlags, { default: 'debug' });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this need to default to debug? for whom are these debug logs useful atm?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly for appex-qa to evaluate parallel testing with Kibana spaces and spot some slow API calls. If we see a repetitive API calls taking 10 seconds to setup env, we usually ask to consider improvement. The end goal is not only move to playwright, but finally start writing stable, fast and reliable tests.

Copy link
Contributor

@mistic mistic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After the fact we might want to summarise our logging ideas we discussed async so this can become a standard in the codebase. LGTM

@dmlemeshko dmlemeshko merged commit d76a5be into elastic:main Jul 22, 2025
13 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.19, 9.1

https://github.com/elastic/kibana/actions/runs/16454773113

@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
8.19 Backport failed because of merge conflicts
9.1 Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 228841

Questions ?

Please refer to the Backport tool documentation

@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Jul 24, 2025
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create automatically backports add a backport:* label or prevent reminders by adding the backport:skip label.
You can also create backports manually by running node scripts/backport --pr 228841 locally
cc: @dmlemeshko

kertal pushed a commit to kertal/kibana that referenced this pull request Jul 25, 2025
## Summary

- default log level for Playwright fixtures is `info` , afaik default
for FTR and other scripts (but for now to better understand performance
issues we pass `debug` through `node scripts/scout`, to be reverted for
GA)
- `node scripts/scout` will propagate log level from cli flag (e.g.
--debug) with `SCOUT_LOG_LEVEL` env variable to playwright exec command
- since some Team may not use `scripts/scout` command, they can set
`LOG_LEVEL` variable to override to whatever level is needed
if both `LOG_LEVEL` and `SCOUT_LOG_LEVEL` are set, the later has
priority (important for us, shouldn't block others)

### Playwright Integration:
* Replaced the use of `getLogger` with the updated `ScoutLogger` call in
Playwright worker fixtures, enabling log level configuration via
environment variables.
* Modified the Playwright test runner to propagate the log level to the
test environment using the `SCOUT_LOG_LEVEL` variable.

---------

Co-authored-by: David Olaru <dolaru@vaevixen.com>
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create automatically backports add a backport:* label or prevent reminders by adding the backport:skip label.
You can also create backports manually by running node scripts/backport --pr 228841 locally
cc: @dmlemeshko

dmlemeshko added a commit to dmlemeshko/kibana that referenced this pull request Jul 28, 2025
## Summary

- default log level for Playwright fixtures is `info` , afaik default
for FTR and other scripts (but for now to better understand performance
issues we pass `debug` through `node scripts/scout`, to be reverted for
GA)
- `node scripts/scout` will propagate log level from cli flag (e.g.
--debug) with `SCOUT_LOG_LEVEL` env variable to playwright exec command
- since some Team may not use `scripts/scout` command, they can set
`LOG_LEVEL` variable to override to whatever level is needed
if both `LOG_LEVEL` and `SCOUT_LOG_LEVEL` are set, the later has
priority (important for us, shouldn't block others)

### Playwright Integration:
* Replaced the use of `getLogger` with the updated `ScoutLogger` call in
Playwright worker fixtures, enabling log level configuration via
environment variables.
* Modified the Playwright test runner to propagate the log level to the
test environment using the `SCOUT_LOG_LEVEL` variable.

---------

Co-authored-by: David Olaru <dolaru@vaevixen.com>
(cherry picked from commit d76a5be)

# Conflicts:
#	src/platform/packages/shared/kbn-scout/src/playwright/global_hooks/synthtrace_ingestion.ts
@dmlemeshko
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
9.1

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

dmlemeshko added a commit that referenced this pull request Jul 28, 2025
# Backport

This will backport the following commits from `main` to `9.1`:
- [[scout] support log level override
(#228841)](#228841)

<!--- Backport version: 10.0.1 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Dzmitry
Lemechko","email":"dzmitry.lemechko@elastic.co"},"sourceCommit":{"committedDate":"2025-07-22T20:25:49Z","message":"[scout]
support log level override (#228841)\n\n## Summary\n\n- default log
level for Playwright fixtures is `info` , afaik default\nfor FTR and
other scripts (but for now to better understand performance\nissues we
pass `debug` through `node scripts/scout`, to be reverted for\nGA)\n-
`node scripts/scout` will propagate log level from cli flag
(e.g.\n--debug) with `SCOUT_LOG_LEVEL` env variable to playwright exec
command\n- since some Team may not use `scripts/scout` command, they can
set\n`LOG_LEVEL` variable to override to whatever level is needed\nif
both `LOG_LEVEL` and `SCOUT_LOG_LEVEL` are set, the later has\npriority
(important for us, shouldn't block others)\n\n### Playwright
Integration:\n* Replaced the use of `getLogger` with the updated
`ScoutLogger` call in\nPlaywright worker fixtures, enabling log level
configuration via\nenvironment variables.\n* Modified the Playwright
test runner to propagate the log level to the\ntest environment using
the `SCOUT_LOG_LEVEL` variable.\n\n---------\n\nCo-authored-by: David
Olaru
<dolaru@vaevixen.com>","sha":"d76a5befa5ec73425b44c10b24f66a19556a7e83","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport
missing","backport:version","v9.1.0","v8.19.0","ci:scout-ui-tests","v9.2.0"],"title":"[scout]
support log level
override","number":228841,"url":"https://github.com/elastic/kibana/pull/228841","mergeCommit":{"message":"[scout]
support log level override (#228841)\n\n## Summary\n\n- default log
level for Playwright fixtures is `info` , afaik default\nfor FTR and
other scripts (but for now to better understand performance\nissues we
pass `debug` through `node scripts/scout`, to be reverted for\nGA)\n-
`node scripts/scout` will propagate log level from cli flag
(e.g.\n--debug) with `SCOUT_LOG_LEVEL` env variable to playwright exec
command\n- since some Team may not use `scripts/scout` command, they can
set\n`LOG_LEVEL` variable to override to whatever level is needed\nif
both `LOG_LEVEL` and `SCOUT_LOG_LEVEL` are set, the later has\npriority
(important for us, shouldn't block others)\n\n### Playwright
Integration:\n* Replaced the use of `getLogger` with the updated
`ScoutLogger` call in\nPlaywright worker fixtures, enabling log level
configuration via\nenvironment variables.\n* Modified the Playwright
test runner to propagate the log level to the\ntest environment using
the `SCOUT_LOG_LEVEL` variable.\n\n---------\n\nCo-authored-by: David
Olaru
<dolaru@vaevixen.com>","sha":"d76a5befa5ec73425b44c10b24f66a19556a7e83"}},"sourceBranch":"main","suggestedTargetBranches":["9.1","8.19"],"targetPullRequestStates":[{"branch":"9.1","label":"v9.1.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/228841","number":228841,"mergeCommit":{"message":"[scout]
support log level override (#228841)\n\n## Summary\n\n- default log
level for Playwright fixtures is `info` , afaik default\nfor FTR and
other scripts (but for now to better understand performance\nissues we
pass `debug` through `node scripts/scout`, to be reverted for\nGA)\n-
`node scripts/scout` will propagate log level from cli flag
(e.g.\n--debug) with `SCOUT_LOG_LEVEL` env variable to playwright exec
command\n- since some Team may not use `scripts/scout` command, they can
set\n`LOG_LEVEL` variable to override to whatever level is needed\nif
both `LOG_LEVEL` and `SCOUT_LOG_LEVEL` are set, the later has\npriority
(important for us, shouldn't block others)\n\n### Playwright
Integration:\n* Replaced the use of `getLogger` with the updated
`ScoutLogger` call in\nPlaywright worker fixtures, enabling log level
configuration via\nenvironment variables.\n* Modified the Playwright
test runner to propagate the log level to the\ntest environment using
the `SCOUT_LOG_LEVEL` variable.\n\n---------\n\nCo-authored-by: David
Olaru
<dolaru@vaevixen.com>","sha":"d76a5befa5ec73425b44c10b24f66a19556a7e83"}}]}]
BACKPORT-->
@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Jul 28, 2025
@mistic mistic added v9.1.1 and removed v9.1.0 labels Jul 29, 2025
dmlemeshko added a commit to dmlemeshko/kibana that referenced this pull request Aug 4, 2025
## Summary

- default log level for Playwright fixtures is `info` , afaik default
for FTR and other scripts (but for now to better understand performance
issues we pass `debug` through `node scripts/scout`, to be reverted for
GA)
- `node scripts/scout` will propagate log level from cli flag (e.g.
--debug) with `SCOUT_LOG_LEVEL` env variable to playwright exec command
- since some Team may not use `scripts/scout` command, they can set
`LOG_LEVEL` variable to override to whatever level is needed
if both `LOG_LEVEL` and `SCOUT_LOG_LEVEL` are set, the later has
priority (important for us, shouldn't block others)

### Playwright Integration:
* Replaced the use of `getLogger` with the updated `ScoutLogger` call in
Playwright worker fixtures, enabling log level configuration via
environment variables.
* Modified the Playwright test runner to propagate the log level to the
test environment using the `SCOUT_LOG_LEVEL` variable.

---------

Co-authored-by: David Olaru <dolaru@vaevixen.com>
(cherry picked from commit d76a5be)

# Conflicts:
#	src/platform/packages/shared/kbn-scout/src/playwright/global_hooks/synthtrace_ingestion.ts
@dmlemeshko
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
8.19

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

dmlemeshko added a commit that referenced this pull request Aug 4, 2025
# Backport

This will backport the following commits from `main` to `8.19`:
- [[scout] support log level override
(#228841)](#228841)

<!--- Backport version: 10.0.0 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Dzmitry
Lemechko","email":"dzmitry.lemechko@elastic.co"},"sourceCommit":{"committedDate":"2025-07-22T20:25:49Z","message":"[scout]
support log level override (#228841)\n\n## Summary\n\n- default log
level for Playwright fixtures is `info` , afaik default\nfor FTR and
other scripts (but for now to better understand performance\nissues we
pass `debug` through `node scripts/scout`, to be reverted for\nGA)\n-
`node scripts/scout` will propagate log level from cli flag
(e.g.\n--debug) with `SCOUT_LOG_LEVEL` env variable to playwright exec
command\n- since some Team may not use `scripts/scout` command, they can
set\n`LOG_LEVEL` variable to override to whatever level is needed\nif
both `LOG_LEVEL` and `SCOUT_LOG_LEVEL` are set, the later has\npriority
(important for us, shouldn't block others)\n\n### Playwright
Integration:\n* Replaced the use of `getLogger` with the updated
`ScoutLogger` call in\nPlaywright worker fixtures, enabling log level
configuration via\nenvironment variables.\n* Modified the Playwright
test runner to propagate the log level to the\ntest environment using
the `SCOUT_LOG_LEVEL` variable.\n\n---------\n\nCo-authored-by: David
Olaru
<dolaru@vaevixen.com>","sha":"d76a5befa5ec73425b44c10b24f66a19556a7e83","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:version","v8.19.0","ci:scout-ui-tests","v9.2.0","v9.1.1"],"title":"[scout]
support log level
override","number":228841,"url":"https://github.com/elastic/kibana/pull/228841","mergeCommit":{"message":"[scout]
support log level override (#228841)\n\n## Summary\n\n- default log
level for Playwright fixtures is `info` , afaik default\nfor FTR and
other scripts (but for now to better understand performance\nissues we
pass `debug` through `node scripts/scout`, to be reverted for\nGA)\n-
`node scripts/scout` will propagate log level from cli flag
(e.g.\n--debug) with `SCOUT_LOG_LEVEL` env variable to playwright exec
command\n- since some Team may not use `scripts/scout` command, they can
set\n`LOG_LEVEL` variable to override to whatever level is needed\nif
both `LOG_LEVEL` and `SCOUT_LOG_LEVEL` are set, the later has\npriority
(important for us, shouldn't block others)\n\n### Playwright
Integration:\n* Replaced the use of `getLogger` with the updated
`ScoutLogger` call in\nPlaywright worker fixtures, enabling log level
configuration via\nenvironment variables.\n* Modified the Playwright
test runner to propagate the log level to the\ntest environment using
the `SCOUT_LOG_LEVEL` variable.\n\n---------\n\nCo-authored-by: David
Olaru
<dolaru@vaevixen.com>","sha":"d76a5befa5ec73425b44c10b24f66a19556a7e83"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/228841","number":228841,"mergeCommit":{"message":"[scout]
support log level override (#228841)\n\n## Summary\n\n- default log
level for Playwright fixtures is `info` , afaik default\nfor FTR and
other scripts (but for now to better understand performance\nissues we
pass `debug` through `node scripts/scout`, to be reverted for\nGA)\n-
`node scripts/scout` will propagate log level from cli flag
(e.g.\n--debug) with `SCOUT_LOG_LEVEL` env variable to playwright exec
command\n- since some Team may not use `scripts/scout` command, they can
set\n`LOG_LEVEL` variable to override to whatever level is needed\nif
both `LOG_LEVEL` and `SCOUT_LOG_LEVEL` are set, the later has\npriority
(important for us, shouldn't block others)\n\n### Playwright
Integration:\n* Replaced the use of `getLogger` with the updated
`ScoutLogger` call in\nPlaywright worker fixtures, enabling log level
configuration via\nenvironment variables.\n* Modified the Playwright
test runner to propagate the log level to the\ntest environment using
the `SCOUT_LOG_LEVEL` variable.\n\n---------\n\nCo-authored-by: David
Olaru
<dolaru@vaevixen.com>","sha":"d76a5befa5ec73425b44c10b24f66a19556a7e83"}},{"branch":"9.1","label":"v9.1.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/229557","number":229557,"state":"MERGED","mergeCommit":{"sha":"1de8c338657942a87ceaa249b3a220a2ec26af92","message":"[9.1]
[scout] support log level override (#228841) (#229557)\n\n#
Backport\n\nThis will backport the following commits from `main` to
`9.1`:\n- [[scout] support log level
override\n(#228841)](https://github.com/elastic/kibana/pull/228841)\n\n\n\n###
Questions ?\nPlease refer to the [Backport
tool\ndocumentation](https://github.com/sorenlouv/backport)\n\n"}}]}]
BACKPORT-->
@dmlemeshko
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
9.0

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

dmlemeshko added a commit to dmlemeshko/kibana that referenced this pull request Oct 16, 2025
## Summary

- default log level for Playwright fixtures is `info` , afaik default
for FTR and other scripts (but for now to better understand performance
issues we pass `debug` through `node scripts/scout`, to be reverted for
GA)
- `node scripts/scout` will propagate log level from cli flag (e.g.
--debug) with `SCOUT_LOG_LEVEL` env variable to playwright exec command
- since some Team may not use `scripts/scout` command, they can set
`LOG_LEVEL` variable to override to whatever level is needed
if both `LOG_LEVEL` and `SCOUT_LOG_LEVEL` are set, the later has
priority (important for us, shouldn't block others)

### Playwright Integration:
* Replaced the use of `getLogger` with the updated `ScoutLogger` call in
Playwright worker fixtures, enabling log level configuration via
environment variables.
* Modified the Playwright test runner to propagate the log level to the
test environment using the `SCOUT_LOG_LEVEL` variable.

---------

Co-authored-by: David Olaru <dolaru@vaevixen.com>
(cherry picked from commit d76a5be)

# Conflicts:
#	src/platform/packages/shared/kbn-scout/src/playwright/global_hooks/synthtrace_ingestion.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels ci:scout-ui-tests Run Scout UI tests release_note:skip Skip the PR/issue when compiling release notes v8.19.0 v8.19.1 v9.0.9 v9.1.1 v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants