Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
cauemarcondes committed Jun 9, 2021
1 parent 831e2c0 commit 2c4112c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 24 deletions.
3 changes: 1 addition & 2 deletions x-pack/plugins/apm/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
"embeddable",
"infra",
"observability",
"ruleRegistry",
"fleet"
"ruleRegistry"
],
"optionalPlugins": [
"spaces",
Expand Down
13 changes: 0 additions & 13 deletions x-pack/plugins/apm/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
16 changes: 7 additions & 9 deletions x-pack/plugins/apm/server/routes/fleet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
},
});
Expand Down

0 comments on commit 2c4112c

Please sign in to comment.