diff --git a/x-pack/plugins/apm/public/plugin.ts b/x-pack/plugins/apm/public/plugin.ts index 9a5c4ff86c314..6e914ad6a94c3 100644 --- a/x-pack/plugins/apm/public/plugin.ts +++ b/x-pack/plugins/apm/public/plugin.ts @@ -75,11 +75,15 @@ export class ApmPlugin implements Plugin { pluginSetupDeps.home.featureCatalogue.register(featureCatalogueEntry); if (plugins.observability) { - plugins.observability.dataAccess.registerProvider( - this.initializerContext.opaqueId, - 'apm', - getObservabilityChartData - ); + plugins.observability.dataAccess.registerProvider({ + pluginOpaqueId: this.initializerContext.opaqueId, + dataType: 'apm', + handler: getObservabilityChartData, + providedContext: { + licensing: plugins.licensing, + home: plugins.home, + }, + }); } core.application.register({ diff --git a/x-pack/plugins/observability/public/data_access_service.ts b/x-pack/plugins/observability/public/data_access_service.ts index 4717dabf745c9..755f4d0e53a50 100644 --- a/x-pack/plugins/observability/public/data_access_service.ts +++ b/x-pack/plugins/observability/public/data_access_service.ts @@ -15,10 +15,14 @@ export class ObservabilityDataAccessService implements Plugin { this.contextContainer = core.context.createContextContainer(); const api: Setup = { - registerProvider: (pluginOpaqueId, dataType, handler) => { + registerProvider: ({ pluginOpaqueId, dataType, handler, providedContext }) => { if (!this.contextContainer) { throw new Error("Context container wasn't defined"); } + if (providedContext) { + this.contextContainer!.registerContext(pluginOpaqueId, dataType, () => providedContext); + } + this.dataProviders.set( dataType, this.contextContainer.createHandler(pluginOpaqueId, handler) diff --git a/x-pack/plugins/observability/public/typings/data_access_service.d.ts b/x-pack/plugins/observability/public/typings/data_access_service.d.ts index 6481839c2ecee..da4cb3a332cf1 100644 --- a/x-pack/plugins/observability/public/typings/data_access_service.d.ts +++ b/x-pack/plugins/observability/public/typings/data_access_service.d.ts @@ -13,11 +13,17 @@ export type DataAccessHandlerProvider = ( ) => ReturnType; export interface Setup { - registerProvider: ( - pluginOpaqueId: symbol, - dataType: string, - handler: DataAccessHandlerProvider - ) => void; + registerProvider: ({ + pluginOpaqueId, + dataType, + handler, + providedContext, + }: { + pluginOpaqueId: symbol; + dataType: string; + handler: DataAccessHandlerProvider; + providedContext?: Record; + }) => void; registerContext: ( pluginOpaqueId: symbol, contextDataType: string,