diff --git a/x-pack/plugins/apm/kibana.json b/x-pack/plugins/apm/kibana.json index a5fbcb67b68312..21aef379715c7d 100644 --- a/x-pack/plugins/apm/kibana.json +++ b/x-pack/plugins/apm/kibana.json @@ -11,8 +11,7 @@ "embeddable", "infra", "observability", - "ruleRegistry", - "fleet" + "ruleRegistry" ], "optionalPlugins": [ "spaces", diff --git a/x-pack/plugins/apm/server/plugin.ts b/x-pack/plugins/apm/server/plugin.ts index 1b5377b835c470..c9391eba29f8da 100644 --- a/x-pack/plugins/apm/server/plugin.ts +++ b/x-pack/plugins/apm/server/plugin.ts @@ -103,19 +103,6 @@ export class APMPlugin }); } - const resourcePlugins = mapValues(plugins, (value, key) => { - return { - setup: value, - start: () => - core.getStartServices().then((services) => { - const [, pluginsStartContracts] = services; - return pluginsStartContracts[ - key as keyof APMPluginStartDependencies - ]; - }), - }; - }) as APMRouteHandlerResources['plugins']; - plugins.home?.tutorials.registerTutorial( tutorialProvider({ isEnabled: this.currentConfig['xpack.apm.ui.enabled'], diff --git a/x-pack/plugins/apm/server/routes/fleet.ts b/x-pack/plugins/apm/server/routes/fleet.ts index 72e2571fe1bb47..e2a394414308a8 100644 --- a/x-pack/plugins/apm/server/routes/fleet.ts +++ b/x-pack/plugins/apm/server/routes/fleet.ts @@ -5,21 +5,19 @@ * 2.0. */ +import { getApmPackgePolicies } from '../lib/fleet/get_apm_package_policies'; import { createApmServerRoute } from './create_apm_server_route'; import { createApmServerRouteRepository } from './create_apm_server_route_repository'; const hasFleetDataRoute = createApmServerRoute({ endpoint: 'GET /api/apm/fleet/has_data', options: { tags: [] }, - handler: async (resources) => { - const { core } = resources.context; - const savedObjectsClient = core.savedObjects.client; - const fleetPluginStart = await resources.plugins.fleet.start(); - - const packagePolicies = await fleetPluginStart.packagePolicyService.list( - savedObjectsClient, - { kuery: 'ingest-package-policies.package.name:apm' } - ); + handler: async ({ core, plugins }) => { + const fleetPluginStart = await plugins.fleet.start(); + const packagePolicies = await getApmPackgePolicies({ + core, + fleetPluginStart, + }); return { hasData: packagePolicies.total > 0 }; }, });