-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Embeddable Rebuild] [O11y] Decouple O11y profiling embeddables from …
…legacy embeddable factory (#184466) Fixes #179290, #179291, #179292, #179293 Part of #167429 ## Summary Decouples the legacy embeddable factory from O11y profiling plugin. The class-based embeddable factory is being removed in preference to a [React embeddable factory](#167429). The profiling plugin was using the legacy embeddable factory to register profiling components that could be shared to other observability plugins. While not strictly enforced, the embeddable registry is expected to be used _only_ for embedding components into Dashboards and Canvas. The embeddables registered by the Profiling plugin were never made available to Dashboards or Canvas. And based on offline discussions with Observability leadership, it is not expected that Profiling components will be made available for embedding on Dashboards or Canvas in the near future. In this PR, I have removed the legacy embeddable usage from the Profiling plugin. The Observability shared plugin now includes a custom registration method for the profiling plugin to register React components so they can be shared to other plugins. This avoids any circular dependency concerns while still allowing other Observability plugins to "embed" profiling components in their pages.
- Loading branch information
Showing
25 changed files
with
348 additions
and
447 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...y_solution/observability_shared/public/components/profiling/helpers/component_registry.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
|
||
const registry: { [key: string]: React.FC<any> } = {}; | ||
|
||
export const registerProfilingComponent = <T>(key: string, component: React.FC<T>) => { | ||
if (registry[key] !== undefined) { | ||
throw new Error( | ||
i18n.translate('xpack.observabilityShared.profilingComponentAlreadyExists.error', { | ||
defaultMessage: `Component with key {key} already exists`, | ||
values: { key }, | ||
}) | ||
); | ||
} | ||
registry[key] = component; | ||
}; | ||
|
||
export const getProfilingComponent = <T>(key: string): React.FC<T> => { | ||
if (registry[key] === undefined) { | ||
throw new Error( | ||
i18n.translate('xpack.observabilityShared.profilingComponentNotFound.error', { | ||
defaultMessage: `Component with key {key} not found`, | ||
values: { key }, | ||
}) | ||
); | ||
} | ||
return registry[key]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 0 additions & 43 deletions
43
...ability_solution/profiling/public/embeddables/flamegraph/embeddable_flamegraph_factory.ts
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
x-pack/plugins/observability_solution/profiling/public/embeddables/flamegraph/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { dynamic } from '@kbn/shared-ux-utility'; | ||
import type { EmbeddableFlamegraphSharedComponent, FlamegraphProps } from './embeddable_flamegraph'; | ||
import { ProfilingEmbeddablesDependencies } from '../profiling_embeddable_provider'; | ||
|
||
const LazyEmbeddableFlamegraph = dynamic(async () => { | ||
const Component = await import('./embeddable_flamegraph'); | ||
return { default: Component.EmbeddableFlamegraph }; | ||
}); | ||
|
||
export const getEmbeddableFlamegraphComponent = ( | ||
profilingEmbeddableDependencies: ProfilingEmbeddablesDependencies | ||
): EmbeddableFlamegraphSharedComponent => { | ||
return (props: FlamegraphProps) => { | ||
return <LazyEmbeddableFlamegraph {...props} {...profilingEmbeddableDependencies} />; | ||
}; | ||
}; |
Oops, something went wrong.