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

Add lazy loading to APM AlertTypes #66189

Closed
gmmorris opened this issue May 12, 2020 · 2 comments · Fixed by #68806
Closed

Add lazy loading to APM AlertTypes #66189

gmmorris opened this issue May 12, 2020 · 2 comments · Fixed by #68806
Assignees
Labels
Feature:Alerting Team:APM All issues that need APM UI Team support

Comments

@gmmorris
Copy link
Contributor

Hey team,
In the Alerting team we've been addressing an issue where Kibana is forced to pre-load a bunch of React components at startup that aren't actually needed until the Alerting UI or flyout are opened: #65678 (Once this PR is merged)

Sadly, this requires changes in how the AlertTypes are actually registered by solutions and so we'd ask that, when you have capacity to do so, you make a small change in how you register your alerts.

In the case of APM looks like we have two AlertTypes that need to change:

alertParamsExpression: ErrorRateAlertTrigger,

alertParamsExpression: TransactionDurationAlertTrigger,

Luckily, changing your AlertType to load lazily is relatively straight forward and you can look at the built-in IndexThreshold AlertType as an example:

  1. Export your Expression component as a default export - as this is a hard requirement for lazy loading.

  2. Pass an React.LazyExoticComponent to the AlertType instead of the regular React.FC

That's about it.
Thanks 😊

@gmmorris gmmorris added Team:APM All issues that need APM UI Team support Feature:Alerting labels May 12, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/apm-ui (Team:apm)

@smith smith self-assigned this Jun 10, 2020
smith added a commit to smith/kibana that referenced this issue Jun 10, 2020
Use `React.lazy` to load the alert triggers so the code doesn't load until the alert flyout is opened.

Fixes elastic#66189.
@smith
Copy link
Contributor

smith commented Jun 10, 2020

@gmmorris added in #68806. Thanks for the detailed instructions!

smith added a commit that referenced this issue Jun 10, 2020
Use `React.lazy` to load the alert triggers so the code doesn't load until the alert flyout is opened.

Fixes #66189.
smith added a commit to smith/kibana that referenced this issue Jun 10, 2020
Use `React.lazy` to load the alert triggers so the code doesn't load until the alert flyout is opened.

Fixes elastic#66189.
smith added a commit that referenced this issue Jun 11, 2020
Use `React.lazy` to load the alert triggers so the code doesn't load until the alert flyout is opened.

Fixes #66189.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Alerting Team:APM All issues that need APM UI Team support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants