mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -04:00
This PR removes the Profiling dependency from APM, introduced on `8.10`. - Exposes a new service in profiling-data-access plugin - Create a new APM API that calls the new service and checks if Profiling is initialized - Move Locators from the Profiling plugin to the Observability-shared plugin - Move logic to check Profiling status (has_setup/has_data...) from Profiling server to profiling-data-access plugin - Create API tests, testing the status services based on different scenarios: - When profiling hasn't been initialized and there's no data - When profiling is initialized but has no data - When collector integration is not installed - When symbolized integration is not installed - When APM server integration is not found --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
63 lines
2 KiB
TypeScript
63 lines
2 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 type {
|
|
CoreSetup,
|
|
CoreStart,
|
|
Logger,
|
|
Plugin,
|
|
PluginInitializerContext,
|
|
} from '@kbn/core/server';
|
|
import { ProfilingConfig } from '.';
|
|
import { registerServices } from './services/register_services';
|
|
import { createProfilingEsClient } from './utils/create_profiling_es_client';
|
|
import { ProfilingPluginStartDeps } from './types';
|
|
|
|
export type ProfilingDataAccessPluginSetup = ReturnType<ProfilingDataAccessPlugin['setup']>;
|
|
export type ProfilingDataAccessPluginStart = ReturnType<ProfilingDataAccessPlugin['start']>;
|
|
|
|
export class ProfilingDataAccessPlugin implements Plugin {
|
|
private readonly logger: Logger;
|
|
|
|
constructor(private readonly initializerContext: PluginInitializerContext<ProfilingConfig>) {
|
|
this.logger = initializerContext.logger.get();
|
|
}
|
|
public setup(core: CoreSetup) {}
|
|
|
|
public start(core: CoreStart, plugins: ProfilingPluginStartDeps) {
|
|
const config = this.initializerContext.config.get();
|
|
|
|
const profilingSpecificEsClient = config.elasticsearch
|
|
? core.elasticsearch.createClient('profiling', {
|
|
hosts: [config.elasticsearch.hosts],
|
|
username: config.elasticsearch.username,
|
|
password: config.elasticsearch.password,
|
|
})
|
|
: undefined;
|
|
|
|
const services = registerServices({
|
|
createProfilingEsClient: ({ esClient: defaultEsClient, useDefaultAuth = false }) => {
|
|
const esClient =
|
|
profilingSpecificEsClient && !useDefaultAuth
|
|
? profilingSpecificEsClient.asInternalUser
|
|
: defaultEsClient;
|
|
|
|
return createProfilingEsClient({ esClient });
|
|
},
|
|
logger: this.logger,
|
|
deps: {
|
|
fleet: plugins.fleet,
|
|
cloud: plugins.cloud,
|
|
},
|
|
});
|
|
|
|
// called after all plugins are set up
|
|
return {
|
|
services,
|
|
};
|
|
}
|
|
}
|