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

[SLO] Fix SLO plugin context #183966

Merged
merged 7 commits into from
May 22, 2024
Merged

Conversation

mgiota
Copy link
Contributor

@mgiota mgiota commented May 21, 2024

Fixes #183967

This PR reverts the changes introduced in this PR regarding SLO Plugin context.

Before

Notice how the embeddable breaks when user clicks on the group accordion in order to expand it.

broken.mov

After

This is the fixed version, where clicking on the group shows the respective SLOs

fixed.mov

@apmmachine
Copy link
Contributor

🤖 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!)

@mgiota mgiota marked this pull request as ready for review May 21, 2024 21:24
@mgiota mgiota requested a review from a team as a code owner May 21, 2024 21:24
@mgiota mgiota changed the title fix slo plugin context [SLO] fix slo plugin context May 21, 2024
@mgiota mgiota changed the title [SLO] fix slo plugin context [SLO] Fix SLO plugin context May 21, 2024
@mgiota mgiota self-assigned this May 21, 2024
@mgiota mgiota added the Team:obs-ux-management Observability Management User Experience Team label May 21, 2024
@elasticmachine
Copy link
Contributor

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

@mgiota mgiota added v8.15.0 Feature:SLO bug Fixes for quality problems that affect the customer experience release_note:skip Skip the PR/issue when compiling release notes labels May 21, 2024
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.

Can we please add a functional e2e test for this?

@botelastic botelastic bot added the ci:project-deploy-observability Create an Observability project label May 22, 2024
Comment on lines 13 to 16
const context = useContext(PluginContext);
if (!context) {
throw new Error('Plugin context value is missing!');
}
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this removed?

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 pretty much reverted the changes that broke it. As discussed, I am actually refactoring it and I will bring this back


export const PluginContext = createContext<PluginContextValue | null>(null);
export const PluginContext = createContext(
{} as PluginContextValue | OverviewEmbeddableContextValue
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't this always be PluginContextValue ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On a dashboard context it should be OverviewEmbeddableContextValue otherwise PluginContextValue. Let me push the refactored code. I disabled an eslint rule though to make it work, so I'd like your thoughts on this.

const executionContextName = executionContext.get().name;

const { observabilityRuleTypeRegistry } =
// eslint-disable-next-line react-hooks/rules-of-hooks
Copy link
Contributor Author

@mgiota mgiota May 22, 2024

Choose a reason for hiding this comment

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

@shahzad31 This solution works, but honestly I don't like I had to disable this eslint rule. Instead I am thinking to do the executionContext check in this file x-pack/plugins/observability_solution/slo/public/pages/slos/components/common/burn_rate_rule_flyout.tsx and pass the context as a param in the useGetFilteredRuleTypes function. What do you think?

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 will also need to change the way useGetFilteredRuleTypes is called in one more place as well x-pack/plugins/observability_solution/slo/public/pages/slos/components/compact_view/slo_list_compact_view.tsx.

@mgiota
Copy link
Contributor Author

mgiota commented May 22, 2024

@shahzad31 I refactored as per our discussion in this commit, where I created a new SloOverviewEmbeddableContext. Everything works, but I get a ts error in all slo pages that use ObservabilityPageTemplate, since I made it optional. Do you know how I can fix? Above ts error is the reason I didn't use this approach in the first place.

Screenshot 2024-05-22 at 11 21 10

@mgiota mgiota requested a review from shahzad31 May 22, 2024 09:24
@mgiota mgiota requested a review from shahzad31 May 22, 2024 09:32
@@ -16,14 +16,8 @@ export interface PluginContextValue {
isServerless?: boolean;
appMountParameters?: AppMountParameters;
observabilityRuleTypeRegistry: ObservabilityRuleTypeRegistry;
ObservabilityPageTemplate: React.ComponentType<LazyObservabilityPageTemplateProps>;
ObservabilityPageTemplate?: React.ComponentType<LazyObservabilityPageTemplateProps>;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@shahzad31 I don't know how to proceed with the ts error I got regarding ObservabilityPageTemplate. Any ideas?

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.

SLO Oveview ebeddable group-by is now working !!

@mgiota mgiota enabled auto-merge (squash) May 22, 2024 10:56
@kibana-ci
Copy link
Collaborator

kibana-ci commented May 22, 2024

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
slo 845 846 +1

Async chunks

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

id before after diff
slo 870.2KB 870.4KB +160.0B

Canvas Sharable Runtime

The Canvas "shareable runtime" is an bundle produced to enable running Canvas workpads outside of Kibana. This bundle is included in third-party webpages that embed canvas and therefor should be as slim as possible.

id before after diff
module count - 5410 +5410
total size - 8.8MB +8.8MB

Page load bundle

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

id before after diff
slo 22.9KB 22.9KB -66.0B

History

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

cc @mgiota

@mgiota mgiota merged commit e6614fa into elastic:main May 22, 2024
20 checks passed
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting bug Fixes for quality problems that affect the customer experience ci:project-deploy-observability Create an Observability project Feature:SLO release_note:skip Skip the PR/issue when compiling release notes Team:obs-ux-management Observability Management User Experience Team v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[SLO] SLO Group by Overview Embeddable is broken
6 participants