Skip to content
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

Stronger typing for monitoring configs #125467

Merged
merged 13 commits into from
Feb 16, 2022

Conversation

matschaffer
Copy link
Contributor

@matschaffer matschaffer commented Feb 14, 2022

Fixes #112146

Summary

This isolates MonitoringConfigSchema (from kibana.yml) from MonitoringConfig (the createConfig return). This allows usage of MonitoringConfig to properly type config access in the rest of the plugin.

To use it, I've replaced all the various formations of config.get => string | undefined around the monitoring plugin.

It's kind of a deep cut, but I didn't see a good way "upgrade" the config.get calls to be properly typed.

Checklist

Delete any items that are not applicable to this PR.

For maintainers

This isolates `MonitoringConfigSchema` (from kibana.yml) from `MonitoringConfig` (the `createConfig` return). This should allow usage of `MonitoringConfig` to properly type config access in the rest of the plugin.
@matschaffer
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

expected head sha didn’t match current head ref.

@@ -257,3 +250,5 @@ export interface PipelineVersion {
lastSeen: number;
hash: string;
}

export type MonitoringConfigSchema = TypeOf<typeof configSchema>;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had a hard time deciding what to call this. If I follow core it would be called MonitoringConfigType (

export type ElasticsearchConfigType = TypeOf<typeof configSchema>;
) but that seemed like a mismatch with the typeof input (configSchema).

As far as I can see, we need to isolate MonitoringConfigSchema (the input config) from MonitoringConfig (the config used across the app) due to the creation of a MonitoringElasticsearchConfig object at ui.elasticsearch in the structure.

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps this is less critical since the code mainly refers to MonitoringConfig?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍🏻 I like that logic

@matschaffer matschaffer marked this pull request as ready for review February 15, 2022 06:40
@matschaffer matschaffer requested a review from a team as a code owner February 15, 2022 06:40
@matschaffer
Copy link
Contributor Author

@elasticmachine merge upstream

@matschaffer matschaffer added auto-backport Deprecated - use backport:version if exact versions are needed Feature:Stack Monitoring release_note:fix Team:Infra Monitoring UI - DEPRECATED DEPRECATED - Label for the Infra Monitoring UI team. Use Team:obs-ux-infra_services v8.1.0 labels Feb 15, 2022
@elasticmachine
Copy link
Contributor

Pinging @elastic/infra-monitoring-ui (Team:Infra Monitoring UI)

@matschaffer
Copy link
Contributor Author

Ah, tests will need a fair bit of updating as well. Moving back to draft while I work on that.

@matschaffer matschaffer marked this pull request as draft February 15, 2022 06:59
Copy link
Contributor

@miltonhultgren miltonhultgren left a comment

Choose a reason for hiding this comment

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

Much better! So much accidental complexity removed, and the domain is now more expressive 👏🏼

@@ -257,3 +250,5 @@ export interface PipelineVersion {
lastSeen: number;
hash: string;
}

export type MonitoringConfigSchema = TypeOf<typeof configSchema>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps this is less critical since the code mainly refers to MonitoringConfig?

@@ -370,9 +347,10 @@ export class MonitoringPlugin
}
},
server: {
instanceUuid: this.legacyShimDependencies.instanceUuid,
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice. Much better to put it under a dedicated key!

@matschaffer
Copy link
Contributor Author

Thanks @miltonhultgren ! Now to just get the api tests to agree (and me remembering how to run the tests again 🤣 )

matschaffer referenced this pull request Feb 16, 2022
* Read from metricbeat-* for node_stats

* Fix tests

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
A number of these were in JS files which also had things like incorrect arg counts on function calls, so I fixed those up too.
@matschaffer
Copy link
Contributor Author

@elasticmachine merge upstream

@matschaffer matschaffer marked this pull request as ready for review February 16, 2022 04:48
@kibanamachine
Copy link
Contributor

expected head sha didn’t match current head ref.

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Test Failures

  • [job] [logs] Default CI Group #21 / apps transform basic license transform permissions for user with full transform access with data loaded should display controls in the edit flyout correctly
  • [job] [logs] Default CI Group #1 / Execution context Browser apps dashboard app propagates context for Vertical bar visualization
  • [job] [logs] Default CI Group #15 / machine learning model management trained models for ML user with read-only access renders expanded row content correctly for model with pipelines

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
monitoring 10 9 -1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
monitoring 471.5KB 471.4KB -104.0B

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
monitoring 2 1 -1
Unknown metric groups

API count

id before after diff
monitoring 10 11 +1

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @matschaffer

@matschaffer matschaffer merged commit de206fb into elastic:main Feb 16, 2022
@matschaffer matschaffer deleted the 112146-sm-config-typing branch February 16, 2022 12:41
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Feb 16, 2022
@kibanamachine
Copy link
Contributor

The following labels were identified as gaps in your version labels and will be added automatically:

  • v8.2.0

If any of these should not be on your pull request, please manually remove them.

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Feb 16, 2022
Replaces previous `config.get` pattern typed to `string | undefined` with a full `MonitoringConfig` type.

(cherry picked from commit de206fb)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.1

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

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Feb 16, 2022
Replaces previous `config.get` pattern typed to `string | undefined` with a full `MonitoringConfig` type.

(cherry picked from commit de206fb)

Co-authored-by: Mat Schaffer <mat@elastic.co>
@tylersmalley tylersmalley added ci:cloud-deploy Create or update a Cloud deployment and removed ci:deploy-cloud labels Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed backport:skip This commit does not require backporting ci:cloud-deploy Create or update a Cloud deployment Feature:Stack Monitoring release_note:fix Team:Infra Monitoring UI - DEPRECATED DEPRECATED - Label for the Infra Monitoring UI team. Use Team:obs-ux-infra_services v8.1.0 v8.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Monitoring] Correctly type kibana config
6 participants