-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Stronger typing for monitoring configs #125467
Conversation
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.
@elasticmachine merge upstream |
expected head sha didn’t match current head ref. |
Additionally, a few cases where we retrieved `server.uuid` were replaced with a new `instanceUuid` field on LegacyServer.
@@ -257,3 +250,5 @@ export interface PipelineVersion { | |||
lastSeen: number; | |||
hash: string; | |||
} | |||
|
|||
export type MonitoringConfigSchema = TypeOf<typeof configSchema>; |
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 had a hard time deciding what to call this. If I follow core it would be called MonitoringConfigType
(
export type ElasticsearchConfigType = TypeOf<typeof configSchema>; |
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.
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.
Perhaps this is less critical since the code mainly refers to MonitoringConfig
?
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 like that logic
@elasticmachine merge upstream |
Pinging @elastic/infra-monitoring-ui (Team:Infra Monitoring UI) |
Ah, tests will need a fair bit of updating as well. Moving back to draft while I work on that. |
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.
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>; |
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.
Perhaps this is less critical since the code mainly refers to MonitoringConfig
?
@@ -370,9 +347,10 @@ export class MonitoringPlugin | |||
} | |||
}, | |||
server: { | |||
instanceUuid: this.legacyShimDependencies.instanceUuid, |
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.
Nice. Much better to put it under a dedicated key!
Thanks @miltonhultgren ! Now to just get the api tests to agree (and me remembering how to run the tests again 🤣 ) |
* 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.
@elasticmachine merge upstream |
expected head sha didn’t match current head ref. |
💛 Build succeeded, but was flakyTest Failures
Metrics [docs]Public APIs missing comments
Async chunks
Public APIs missing exports
History
To update your PR or re-run it, just comment with: cc @matschaffer |
The following labels were identified as gaps in your version labels and will be added automatically:
If any of these should not be on your pull request, please manually remove them. |
Replaces previous `config.get` pattern typed to `string | undefined` with a full `MonitoringConfig` type. (cherry picked from commit de206fb)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
Fixes #112146
Summary
This isolates
MonitoringConfigSchema
(fromkibana.yml
) fromMonitoringConfig
(thecreateConfig
return). This allows usage ofMonitoringConfig
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