kibana/x-pack/plugins/metrics_data_access/server/plugin.ts
Kevin Lacabane f1fa4b0b98
[apm][infra] remove infra dependency from apm (#167531)
## Summary

Closes https://github.com/elastic/kibana/issues/166834

Moves the following components out of infra plugin so we can remove the
apm->infra dependency
- `/infra/metrics_explorer` route
- (Host|Pod|Container)MetricsTable components
- InfraAppId
- InfraLocators

### Testing
We should focus the testing on the metrics_explorer route which is used
by 1. Tables in the Infrastructure section of apm and 2. Infrastructure
> Metrics explorer app. No functionality was added so these apps should
have the same existing behavior. Easiest way to get these views loaded
is by connecting kibana to an edge-oblt cluster, alternatively load
service and metrics with a data loader.

### Follow up
- (Host|Pod|Container)MetricsTable components are part of the
metricsDataAccess plugin contract but should be moved to stateless
package

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Jason Rhodes <jason.rhodes@elastic.co>
2023-11-02 16:28:32 +02:00

49 lines
1.5 KiB
TypeScript

/*
* 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 {
CoreSetup,
PluginInitializerContext,
Plugin,
RequestHandlerContext,
} from '@kbn/core/server';
import { MetricsDataPluginSetup, MetricsDataPluginStartDeps } from './types';
import { MetricsDataClient } from './client';
import { metricsDataSourceSavedObjectType } from './saved_objects/metrics_data_source';
import { KibanaFramework } from './lib/adapters/framework/kibana_framework_adapter';
import { initMetricExplorerRoute } from './routes/metrics_explorer';
import { initMetricIndicesRoute } from './routes/metric_indices';
export class MetricsDataPlugin implements Plugin<MetricsDataPluginSetup, {}, {}, {}> {
private metricsClient: MetricsDataClient | null = null;
constructor(context: PluginInitializerContext) {}
public setup(core: CoreSetup<MetricsDataPluginStartDeps>) {
const router = core.http.createRouter();
const framework = new KibanaFramework(core, router);
initMetricExplorerRoute(framework);
initMetricIndicesRoute<RequestHandlerContext>({
router,
metricsClient: new MetricsDataClient(),
});
core.savedObjects.registerType(metricsDataSourceSavedObjectType);
this.metricsClient = new MetricsDataClient();
return {
client: this.metricsClient,
};
}
public start() {
return {};
}
public stop() {}
}