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

[Discover] Context aware extension framework development #181528

Closed
tonyghiani opened this issue Apr 24, 2024 · 2 comments · Fixed by #181952
Closed

[Discover] Context aware extension framework development #181528

tonyghiani opened this issue Apr 24, 2024 · 2 comments · Fixed by #181952
Assignees
Labels
Feature:Discover Discover Application Project:OneDiscover Enrich Discover with contextual awareness Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. Team:obs-ux-logs Observability Logs User Experience Team

Comments

@tonyghiani
Copy link
Contributor

📓 Summary

To prevent cyclic dependencies between plugins/packages, it is necessary to have still a mechanism to register external dependencies functionalities. Until now, the extension points have been created to customize some specific UI parts of Discover, such as the flyout content, the sidebar, the top nav, etc.

I believe we should switch to a more Discover-opinionated extension system, where high-level features can be optionally registered and strictly when is not possible to push them down into the Discover codebase, but the responsibility to render them somewhere on the UI is delegated to Discover only.
For example, something like this could be an idea of what it could look like:

// In the obs context
discoverRegistry.registerFeature({
  id: 'ai-assistant', // Constrained available features, no generic `flyout` or `header` pointing to UI areas
  render: (discoverDeps) => <ObsAIAssistant />
})

// In the security context
discoverRegistry.registerFeature({
  id: 'ai-assistant',
  render: (discoverDeps) => <SecurityAIAssistant />
})

// Need to inject custom uiSettings service
discoverRegistry.registerFeature({
  id: 'services',
  getServices: (discoverDeps) => ({uiSettings: customUiSettings})
})

Dependency injection for Discover extensions

Regarding how the dependency injection is managed, the extensions registry currently lives inside the discover plugin, which makes the dependency tree look like:

flowchart TD

B(Logs Explorer) --> A[Discover]
C(Security) --> A[Discover]
D(Any app) --> A[Discover]
Loading

This works although creates a direct dependency on Discover from any consumer.

As this registry doesn't rely on particular lifecycle hooks, we could factor it out into a package which works as an IoC container for Discover features, which would make the dependency tree look something like:

flowchart TD

A(Discover) -- Get --> E[DiscoverFeaturesRegistry]
B(Logs Explorer) -- Set --> E[DiscoverFeaturesRegistry]
C(Security) -- Set --> E[DiscoverFeaturesRegistry]
D(Any app) -- Set --> E[DiscoverFeaturesRegistry]
Loading

It would so reflect the decisions taken in https://github.com/elastic/kibana/pull/166524/files?short_path=569daf5#diff-569daf56743cc51d98ac5239825483015505fdce810a0afaa6dd353e1d3caade and reduce the coupling between dependencies.
Details need to be defined, although some experimental work will start on the first part of this migration.

@tonyghiani tonyghiani self-assigned this Apr 24, 2024
@botelastic botelastic bot added the needs-team Issues missing a team label label Apr 24, 2024
@tonyghiani tonyghiani added Feature:Discover Discover Application Team:obs-ux-logs Observability Logs User Experience Team Project:OneDiscover Enrich Discover with contextual awareness and removed needs-team Issues missing a team label labels Apr 24, 2024
@elasticmachine
Copy link
Contributor

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

@tonyghiani tonyghiani added the Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. label Apr 24, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)

@tonyghiani tonyghiani changed the title Context aware extension framework development [Discover] Context aware extension framework development Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Discover Discover Application Project:OneDiscover Enrich Discover with contextual awareness Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. Team:obs-ux-logs Observability Logs User Experience Team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants