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

chore(slo): Migrate to server-route-repository #198726

Merged
merged 56 commits into from
Nov 12, 2024

Conversation

kdelemme
Copy link
Contributor

@kdelemme kdelemme commented Nov 1, 2024

Resolves #198683

🌸 Summary

This PR migrates the SLO plugin to the new server route repository, so we can leverage the client.
I've added the SLO repository client into the SLO Plugin Context so we can retrieve it from the different Hooks.
The hooks have been updated to use the new SLO repository client. I had to update the SLO embeddable to use this context as well.

I've taken the opportunity to refactor a bit the various Plugin types, but there is a lot left to do, especially around the Context values we provide a bit everywhere with a little bit of everything 🙅🏻

Testing

Create some SLOs, and play around with dashboard embeddable, SLO flyout.

Found issues

  • SLO Burn Rate Alert Details Section App: breaks because the PluginContext is not provided when this page load.

💀 Risks

Check the following clients use the API version header:

❗ Should be fine since kibana default to the latest API version in prod

@kdelemme kdelemme requested a review from a team as a code owner November 6, 2024 16:38
@kdelemme kdelemme force-pushed the chore/migrate-to-core-http-router branch from 9f9aac8 to ab5510c Compare November 6, 2024 16:43
Copy link
Member

@dmlemeshko dmlemeshko left a comment

Choose a reason for hiding this comment

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

Deployment-agnostic tests changes LGTM

Copy link
Contributor Author

@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.

Left some comments for reviewers

/>
</QueryClientProvider>
</Router>
<PluginContext.Provider
Copy link
Contributor Author

Choose a reason for hiding this comment

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

All the embeddables registration would need to be refactored to use a common context providers instead of creating from scratch for the 5 different embeddable we have. Very error prone.

Copy link
Contributor

@mgiota mgiota Nov 8, 2024

Choose a reason for hiding this comment

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

Linking with this comment here. There is indeed an SloEmbeddableContext which I introduced as part of refactoring the alerts embeddable. I will create an issue for this

Comment on lines -91 to -100
if (error instanceof ObservabilityError) {
logger.error(error.message);
return response.customError({
statusCode: getHTTPResponseCode(error),
body: {
message: error.message,
},
});
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was specific to SLO. Since we moved SLO outside of observability/ this handler is not use anymore

Comment on lines +27 to +36
export async function executeWithErrorHandler(fn: () => Promise<any>): Promise<any> {
try {
return await fn();
} catch (error) {
if (error instanceof SLOError) {
throw handleSLOError(error);
}

throw error;
}
Copy link
Contributor Author

@kdelemme kdelemme Nov 7, 2024

Choose a reason for hiding this comment

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

This handler is used to wrap the various route's application services and handle any domain errors thrown by them, by mapping them to their Boom equivalent. Boom errors are then handled by the core router.

Ideally, the core http router would offer a way to provide a custom error handler, but changing this there would require more consideration and agreement with the core team. Which can be discussed and done outside of this PR.

Copy link
Contributor

@shahzad31 shahzad31 left a comment

Choose a reason for hiding this comment

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

Things looks normal !!

Smoke tested following !!

  • Adding/editing SLO
  • SLO details page
  • SLO Overview page
  • Adding an embeddable from SLO page
  • Adding Overview/alerts/burn rate embeddable

Also verified that version header is being provided now in call from UI !!

@elasticmachine
Copy link
Contributor

elasticmachine commented Nov 12, 2024

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
slo 854 868 +14

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
slo 59 44 -15

Async chunks

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

id before after diff
slo 852.7KB 855.1KB +2.4KB

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
slo 1 3 +2

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
slo 24.7KB 28.5KB +3.8KB
Unknown metric groups

API count

id before after diff
slo 59 44 -15

ESLint disabled in files

id before after diff
observability 4 3 -1

ESLint disabled line counts

id before after diff
slo 14 16 +2

Total ESLint disabled count

id before after diff
observability 47 46 -1
slo 18 20 +2
total +1

History

@kdelemme kdelemme merged commit efcc2ab into elastic:main Nov 12, 2024
28 checks passed
@kdelemme kdelemme deleted the chore/migrate-to-core-http-router branch November 12, 2024 21:24
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

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

@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create automatically backports add a backport:* label or prevent reminders by adding the backport:skip label.
You can also create backports manually by running node scripts/backport --pr 198726 locally

@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Nov 13, 2024
@kdelemme
Copy link
Contributor Author

💚 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

kdelemme added a commit to kdelemme/kibana that referenced this pull request Nov 14, 2024
(cherry picked from commit efcc2ab)

# Conflicts:
#	oas_docs/output/kibana.serverless.yaml
#	x-pack/plugins/observability_solution/slo/public/plugin.ts
#	x-pack/plugins/observability_solution/slo/public/types.ts
#	x-pack/plugins/observability_solution/slo/tsconfig.json
kdelemme added a commit that referenced this pull request Nov 14, 2024
# Backport

This will backport the following commits from `main` to `8.x`:
- [chore(slo): Migrate to server-route-repository
(#198726)](#198726)

<!--- Backport version: 8.9.8 -->

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

<!--BACKPORT [{"author":{"name":"Kevin
Delemme","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-12T21:24:53Z","message":"chore(slo):
Migrate to server-route-repository
(#198726)","sha":"efcc2ab004f9888b4307e85cb0a604c79fc39027","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport
missing","v9.0.0","backport:prev-minor","ci:project-deploy-observability","Team:obs-ux-management","v8.17.0"],"number":198726,"url":"https://github.com/elastic/kibana/pull/198726","mergeCommit":{"message":"chore(slo):
Migrate to server-route-repository
(#198726)","sha":"efcc2ab004f9888b4307e85cb0a604c79fc39027"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/198726","number":198726,"mergeCommit":{"message":"chore(slo):
Migrate to server-route-repository
(#198726)","sha":"efcc2ab004f9888b4307e85cb0a604c79fc39027"}},{"branch":"8.x","label":"v8.17.0","labelRegex":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Nov 14, 2024
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Nov 18, 2024
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Nov 18, 2024
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.17.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[SLO] Replace current router with core http router
8 participants