Skip to content

Make core logging independent from the legacy Kibana.#21831

Merged
azasypkin merged 2 commits intoelastic:masterfrom
azasypkin:issue-xxx-core-independent-logging
Aug 15, 2018
Merged

Make core logging independent from the legacy Kibana.#21831
azasypkin merged 2 commits intoelastic:masterfrom
azasypkin:issue-xxx-core-independent-logging

Conversation

@azasypkin
Copy link
Copy Markdown
Contributor

In this PR I decouple core logging from the "legacy" kbnServer.server.log so that core can log before "legacy" Kibana is started or not started at all (e.g. ClusterManager process). It also eliminates the need in passing env that deep in core services/system hierarchy (env should have been passed to Appenders factory).

Surely it may look a bit hackish, but this logging backward compatibility bridge is supposed to die as soon as we switch entire Kibana to use the core own logging system.

Unblocks #19994

@azasypkin azasypkin added Team:Core Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// Feature:New Platform v6.5.0 labels Aug 9, 2018
static async create(opts = {}, settings = {}) {
const transformedSettings = transformDeprecations(settings);
const config = await Config.withDefaultSchema(transformedSettings);
const config = Config.withDefaultSchema(transformedSettings);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

note: I don't see any reason to make async that is really sync :) But the main reason for this change is that with async it's hard to reliably use Config.withDefaultSchema inside constructors.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks like this was made async in #18926, maybe @kobelb can remember if we still need async config loading for Native Controllers for some reason?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I seem to remember that it was a part of an initial attempt to support loading the package.json files from plugins without executing their code, but based on the current state of #18926 it doesn't seem necessary

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Interesting! Now I'm curious what was supposed to be async inside of withDefaultSchema @kobelb ? :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's because of this: https://github.com/elastic/kibana/pull/17496/files#diff-346d12eb90facc1036ff15f93bd825bf

To be able to determine if the system call filters should be enabled by default, we have to manually check the OS version here, which is async: https://github.com/elastic/kibana/pull/17496/files#diff-12472d028fb5d43810d33bc6d77e93c4

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That makes sense, there have been a few other places where I've resorted to using the async default configs as well: https://github.com/elastic/kibana/blob/master/x-pack/plugins/reporting/index.js#L91 https://github.com/elastic/kibana/blob/master/x-pack/plugins/reporting/index.js#L98

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hmm, thanks for sharing! You have quite a few smart defaults :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I somehow found myself in a position where I needed quite a few different defaults for different operating systems, with a really poor way of detecting support....

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One way we can handle this sort of thing in the new platform would be to construct an Environment object before other services that we can pass around to APIs like this. This way by the time something like this would need to determine the operating system, that value would have already been determined and made available synchronously through the Environment.

Copy link
Copy Markdown
Contributor Author

@azasypkin azasypkin Aug 14, 2018

Choose a reason for hiding this comment

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

We do exactly that (almost) with env and installationFeatures (isClusterModeSupported, isOssModeSupported, isXPackInstalled etc.) in new platform: https://github.com/elastic/kibana/pull/19994/files#diff-806634e0e6f42d8ea73cd3565c9089cbR31 . Env can include other environment specific things for sure.

}

/**
* The "legacy" Kibana uses Hapi server + even-better plugin to log, so we should
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

note: I can theoretically just use hapi (v14) instance here, but as I mentioned in comment it feels a bit too much to me (and it's going to be upgraded soon as well), but let me know if you'd rather prefer something else here.

constructor(legacyLoggingConfig: Readonly<Record<string, any>>) {
super();

// We set `ops.interval` to max allowed number and `ops` filter to value
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

note: I dug through source code of even-better and couldn't find a better way to just disable ops monitoring :/

@azasypkin azasypkin requested review from epixa, rhoboat and spalger August 9, 2018 10:36
@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

@rhoboat
Copy link
Copy Markdown

rhoboat commented Aug 15, 2018

Seems we have several reviewers, so removing review request. Please add me again if needed, though.

@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Copy link
Copy Markdown
Contributor

@spalger spalger left a comment

Choose a reason for hiding this comment

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

Pulled the PR, seems to run well, and the code looks good, LGTM!

@azasypkin azasypkin merged commit 1f7fdbf into elastic:master Aug 15, 2018
@azasypkin azasypkin deleted the issue-xxx-core-independent-logging branch August 15, 2018 18:49
azasypkin added a commit that referenced this pull request Aug 16, 2018
* Make core logging independent from the legacy Kibana. (#21831)

* Remove `async` from test `setup` function.
@azasypkin
Copy link
Copy Markdown
Contributor Author

6.x/6.5: 402758f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backported Feature:New Platform Team:Core Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// v6.5.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants