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

[SLOs] Try async creation of resources !! #192836

Merged
merged 21 commits into from
Oct 1, 2024

Conversation

shahzad31
Copy link
Contributor

@shahzad31 shahzad31 commented Sep 13, 2024

Summary

Try async as much as possible while creating SLO !!

Also UI form won't wait now for creating burn rate rule, it will be created async loading state in toast !!

Before

image

After

image

@obltmachine
Copy link

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@shahzad31 shahzad31 marked this pull request as ready for review September 13, 2024 11:39
@shahzad31 shahzad31 requested a review from a team as a code owner September 13, 2024 11:39
@shahzad31 shahzad31 added the release_note:skip Skip the PR/issue when compiling release notes label Sep 13, 2024
@botelastic botelastic bot added ci:project-deploy-observability Create an Observability project Team:obs-ux-management Observability Management User Experience Team labels Sep 13, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ux-management-team (Team:obs-ux-management)

@shahzad31 shahzad31 added the backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) label Sep 24, 2024
Copy link
Contributor

@kdelemme kdelemme left a comment

Choose a reason for hiding this comment

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

Parallelizing the operations is a good improvement, but I think the change in the repository is not acceptable for the reason cited in the comments.

Happy to discuss more.
I might have one idea if we really want to split the exist assertion and the save operation (but including the save operation in the promise.all).

Copy link
Contributor

@kdelemme kdelemme left a comment

Choose a reason for hiding this comment

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

Thanks for the changes, I think we can leverage react query callback functions in the UI. Going to test locally now

return slo;
}

async update(slo: SLODefinition): Promise<SLODefinition> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Technically this function can also create a new SLO 🙈

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 think we can live with that :D

Copy link
Contributor

@kdelemme kdelemme left a comment

Choose a reason for hiding this comment

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

One last comment about usage of the hook

Copy link
Contributor

@kdelemme kdelemme left a comment

Choose a reason for hiding this comment

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

Just need to fix the loadingToastId typing and usage but otherwise LGTM.

Comment on lines 29 to 33
return useMutation<
CreateRuleResponse<Params> & { loadingToastId?: string },
Error,
{ rule: CreateRuleRequestBody<Params> }
>(
Copy link
Contributor

Choose a reason for hiding this comment

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

loadingToastId is not part of the Data response. it belongs to the context, which is the 4th type parameter.

Suggested change
return useMutation<
CreateRuleResponse<Params> & { loadingToastId?: string },
Error,
{ rule: CreateRuleRequestBody<Params> }
>(
return useMutation<
CreateRuleResponse<Params>,
Error,
{ rule: CreateRuleRequestBody<Params> },
{ loadingToastId: string }
>(

Comment on lines 80 to 84
onSettled: (data) => {
if (data?.loadingToastId) {
toasts.remove(data?.loadingToastId);
}
},
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder how this works locally because loadingToastId is in the context variable, which is the 4th argument of the onSettled function: https://tanstack.com/query/v4/docs/framework/react/guides/mutations#mutation-side-effects

data is what is returned by the mutate query function (the API call basically).

Suggested change
onSettled: (data) => {
if (data?.loadingToastId) {
toasts.remove(data?.loadingToastId);
}
},
onSettled: (_, _, _, context) => {
if (context?.loadingToastId) {
toasts.remove(context?.loadingToastId);
}
},

Comment on lines 94 to 96
rollbackOperations.push(() => this.transformManager.stop(rollupTransformId));
rollbackOperations.push(() => this.summaryTransformManager.stop(summaryTransformId));

Copy link
Contributor

Choose a reason for hiding this comment

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

👍🏻

@kibana-ci
Copy link
Collaborator

kibana-ci commented Sep 30, 2024

💛 Build succeeded, but was flaky

  • Buildkite Build
  • Commit: 0d88c2f
  • Kibana Serverless Image: docker.elastic.co/kibana-ci/kibana-serverless:pr-192836-0d88c2f06195

Failed CI Steps

Metrics [docs]

Async chunks

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

id before after diff
slo 854.2KB 854.7KB +538.0B

History

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

Copy link
Contributor

@kdelemme kdelemme left a comment

Choose a reason for hiding this comment

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

Thanks for the changes, tested locally and works as expected!

@shahzad31 shahzad31 merged commit 9e117c3 into elastic:main Oct 1, 2024
23 checks passed
@shahzad31 shahzad31 deleted the slo-create-perf branch October 1, 2024 15:33
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/11128644789

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Oct 1, 2024
## Summary

Try async as much as possible while creating SLO !!

Also UI form won't wait now for creating burn rate rule, it will be
created async loading state in toast !!
### Before

![image](https://github.com/user-attachments/assets/dc73ce58-3fc4-475f-a6ae-71ac98a6432c)

### After

![image](https://github.com/user-attachments/assets/4439bb8b-6768-4d8b-b208-1bad28f17ae5)

(cherry picked from commit 9e117c3)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.x

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 Oct 1, 2024
# Backport

This will backport the following commits from `main` to `8.x`:
- [[SLOs] Try async creation of resources !!
(#192836)](#192836)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT
[{"author":{"name":"Shahzad","email":"shahzad31comp@gmail.com"},"sourceCommit":{"committedDate":"2024-10-01T15:33:29Z","message":"[SLOs]
Try async creation of resources !! (#192836)\n\n## Summary\r\n\r\nTry
async as much as possible while creating SLO !!\r\n\r\nAlso UI form
won't wait now for creating burn rate rule, it will be\r\ncreated async
loading state in toast !!\r\n###
Before\r\n\r\n\r\n![image](https://github.com/user-attachments/assets/dc73ce58-3fc4-475f-a6ae-71ac98a6432c)\r\n\r\n###
After\r\n\r\n\r\n![image](https://github.com/user-attachments/assets/4439bb8b-6768-4d8b-b208-1bad28f17ae5)","sha":"9e117c3aa22f3296cfda2d4f43c1729562290057","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:prev-minor","ci:project-deploy-observability","Team:obs-ux-management"],"title":"[SLOs]
Try async creation of resources
!!","number":192836,"url":"https://github.com/elastic/kibana/pull/192836","mergeCommit":{"message":"[SLOs]
Try async creation of resources !! (#192836)\n\n## Summary\r\n\r\nTry
async as much as possible while creating SLO !!\r\n\r\nAlso UI form
won't wait now for creating burn rate rule, it will be\r\ncreated async
loading state in toast !!\r\n###
Before\r\n\r\n\r\n![image](https://github.com/user-attachments/assets/dc73ce58-3fc4-475f-a6ae-71ac98a6432c)\r\n\r\n###
After\r\n\r\n\r\n![image](https://github.com/user-attachments/assets/4439bb8b-6768-4d8b-b208-1bad28f17ae5)","sha":"9e117c3aa22f3296cfda2d4f43c1729562290057"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/192836","number":192836,"mergeCommit":{"message":"[SLOs]
Try async creation of resources !! (#192836)\n\n## Summary\r\n\r\nTry
async as much as possible while creating SLO !!\r\n\r\nAlso UI form
won't wait now for creating burn rate rule, it will be\r\ncreated async
loading state in toast !!\r\n###
Before\r\n\r\n\r\n![image](https://github.com/user-attachments/assets/dc73ce58-3fc4-475f-a6ae-71ac98a6432c)\r\n\r\n###
After\r\n\r\n\r\n![image](https://github.com/user-attachments/assets/4439bb8b-6768-4d8b-b208-1bad28f17ae5)","sha":"9e117c3aa22f3296cfda2d4f43c1729562290057"}}]}]
BACKPORT-->

Co-authored-by: Shahzad <shahzad31comp@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) ci:project-deploy-observability Create an Observability project release_note:skip Skip the PR/issue when compiling release notes Team:obs-ux-management Observability Management User Experience Team v8.16.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants