-
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
[Infra UI] Refactor Inventory Models #46403
Conversation
💚 Build Succeeded |
💔 Build Failed |
💚 Build Succeeded |
💚 Build Succeeded |
@simianhacker help me out, what's "DSL" stand for here? I only know this as "domain-specific language"… |
@jasonrhodes That's correct sort of like the ES Query DSL but really more accurate would just be Inventory Models. |
💔 Build Failed |
💔 Build Failed |
💔 Build Failed |
💔 Build Failed |
💔 Build Failed |
💚 Build Succeeded |
Pinging @elastic/infra-logs-ui (Team:infra-logs-ui) |
💚 Build Succeeded |
I did a first pass and for a person not familiar with the code I could get the gist of it, so 👍. I don't feel comfortable to approve it yet though. Maybe you could walk me through the code on a call (or wait for someone who is more familiar with it). |
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 think my main takeaway is that all the layout's code should just be react components. I think doing that will help us with maintenance in the long run and make it easier for people to grok.
It's a large refractor and hard for me to understand completely how all of the pieces tie together, so I think it'd be good to add some docs. Mainly, I'd like to know what steps need to be taken to add a new type of inventory? What files would need to be created and where?
|
||
export const containerLayoutCreator: InfraMetricLayoutCreator = theme => [ | ||
export const layout: InventoryDetailLayoutCreator = theme => [ |
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.
After thinking about this, I still think layouts are best expressed on the frontend as react components. Mainly, I think it gives us more flexibility, reduces complexity, and will gives us a better developer experience.
@@ -22,17 +25,17 @@ export const containerDiskIOOps: InfraMetricModelCreator = (timeField, indexPatt | |||
{ | |||
field: 'docker.diskio.read.ops', | |||
id: 'max-diskio-read-ops', | |||
type: InfraMetricModelMetricType.max, | |||
type: 'max', |
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.
Just curious, why remove enums?
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.
Those enums are managed by GraphQL, as part of cleaning up the tech debt I'm making an effort to move everything to IO-TS types which doesn't support enums, but each of those types have been replaced with a t.keyOf({ ... })
which restricts which string it can be.
💚 Build Succeeded |
* [Infra UI] Refactor Inventory DSL * Updating types * Adding types * moving from metric_models to inventory_models * Fixing Kubernetes toolbars * Add models to index file * Removing snapshot metric aggregations in favor of inventory models * Removing TSVB models and replacing with inventory models * Fixing the glorious types * Removing obsolete layouts * removing obsolete message * removing toolbar
* [Infra UI] Refactor Inventory Models (#46403) * [Infra UI] Refactor Inventory DSL * Updating types * Adding types * moving from metric_models to inventory_models * Fixing Kubernetes toolbars * Add models to index file * Removing snapshot metric aggregations in favor of inventory models * Removing TSVB models and replacing with inventory models * Fixing the glorious types * Removing obsolete layouts * removing obsolete message * removing toolbar * Removing obsolete translations * Removing obsolete translations
Summary
This PR refactors ALL the different models into one structure instead of everything being spread all over the project or hard coded in components. The goal is to put all these definitions in one common place and then re-use them on the client and server. These models define the following for each node type (view type):
Toolbar for the inventory page(coming in follow up PR)This should allow us to add new inventory views by just defining the file structures under
inventory_models
. The only time we would need to touch the react code is if there is a new section required like the APM section on the metric detail page OR a new toolbar section for the inventory page (required for AWS).Additionally, this PR also consolidates all the different types (from GraphQL and pure Typescript files) scattered about into one place near the models. All the types are written in IO-TS. This will help with the transition from GraphQL.
Anatomy of an inventory model
Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.This was checked for cross-browser compatibility, including a check against IE11Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n supportDocumentation was added for features that require explanation or tutorialsUnit or functional tests were updated or added to match the most common scenariosThis was checked for keyboard-only and screenreader accessibility