mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
* [APM] Fix timeout in APM setup * Update plugin.ts # Conflicts: # x-pack/plugins/apm/server/lib/index_pattern/get_dynamic_index_pattern.ts # x-pack/plugins/apm/server/lib/settings/agent_configuration/create_agent_config_index.ts # x-pack/plugins/apm/server/plugin.ts
This commit is contained in:
parent
bc41f88f6c
commit
50f15a2357
3 changed files with 16 additions and 18 deletions
|
@ -38,4 +38,4 @@ export function plugin(initializerContext: PluginInitializerContext) {
|
|||
|
||||
export type APMOSSConfig = TypeOf<typeof config.schema>;
|
||||
|
||||
export { APMOSSPlugin as Plugin };
|
||||
export { APMOSSPluginSetup } from './plugin';
|
||||
|
|
|
@ -20,7 +20,7 @@ import { Plugin, CoreSetup, PluginInitializerContext } from 'src/core/server';
|
|||
import { Observable } from 'rxjs';
|
||||
import { APMOSSConfig } from './';
|
||||
|
||||
export class APMOSSPlugin implements Plugin<{ config$: Observable<APMOSSConfig> }> {
|
||||
export class APMOSSPlugin implements Plugin<APMOSSPluginSetup> {
|
||||
constructor(private readonly initContext: PluginInitializerContext) {
|
||||
this.initContext = initContext;
|
||||
}
|
||||
|
@ -36,3 +36,7 @@ export class APMOSSPlugin implements Plugin<{ config$: Observable<APMOSSConfig>
|
|||
start() {}
|
||||
stop() {}
|
||||
}
|
||||
|
||||
export interface APMOSSPluginSetup {
|
||||
config$: Observable<APMOSSConfig>;
|
||||
}
|
||||
|
|
|
@ -10,10 +10,10 @@ import {
|
|||
SavedObjectsClientContract,
|
||||
} from 'src/core/server';
|
||||
import { Observable, combineLatest, AsyncSubject } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { map, take } from 'rxjs/operators';
|
||||
import { Server } from 'hapi';
|
||||
import { once } from 'lodash';
|
||||
import { Plugin as APMOSSPlugin } from '../../../../src/plugins/apm_oss/server';
|
||||
import { APMOSSPluginSetup } from '../../../../src/plugins/apm_oss/server';
|
||||
import { createApmAgentConfigurationIndex } from '../../../legacy/plugins/apm/server/lib/settings/agent_configuration/create_agent_config_index';
|
||||
import { createApmApi } from '../../../legacy/plugins/apm/server/routes/create_apm_api';
|
||||
import { getApmIndices } from '../../../legacy/plugins/apm/server/lib/settings/apm_indices/get_apm_indices';
|
||||
|
@ -33,22 +33,19 @@ export interface APMPluginContract {
|
|||
|
||||
export class APMPlugin implements Plugin<APMPluginContract> {
|
||||
legacySetup$: AsyncSubject<LegacySetup>;
|
||||
currentConfig: APMConfig;
|
||||
constructor(private readonly initContext: PluginInitializerContext) {
|
||||
this.initContext = initContext;
|
||||
this.legacySetup$ = new AsyncSubject();
|
||||
this.currentConfig = {} as APMConfig;
|
||||
}
|
||||
|
||||
public async setup(
|
||||
core: CoreSetup,
|
||||
plugins: {
|
||||
apm_oss: APMOSSPlugin extends Plugin<infer TSetup> ? TSetup : never;
|
||||
apm_oss: APMOSSPluginSetup;
|
||||
}
|
||||
) {
|
||||
const config$ = this.initContext.config.create<APMXPackConfig>();
|
||||
const logger = this.initContext.logger.get('apm');
|
||||
|
||||
const mergedConfig$ = combineLatest(plugins.apm_oss.config$, config$).pipe(
|
||||
map(([apmOssConfig, apmConfig]) => mergeConfigs(apmOssConfig, apmConfig))
|
||||
);
|
||||
|
@ -57,15 +54,12 @@ export class APMPlugin implements Plugin<APMPluginContract> {
|
|||
createApmApi().init(core, { config$: mergedConfig$, logger, __LEGACY });
|
||||
});
|
||||
|
||||
await new Promise(resolve => {
|
||||
mergedConfig$.subscribe(async config => {
|
||||
this.currentConfig = config;
|
||||
await createApmAgentConfigurationIndex({
|
||||
esClient: core.elasticsearch.dataClient,
|
||||
config,
|
||||
});
|
||||
resolve();
|
||||
});
|
||||
const currentConfig = await mergedConfig$.pipe(take(1)).toPromise();
|
||||
|
||||
// create agent configuration index without blocking setup lifecycle
|
||||
createApmAgentConfigurationIndex({
|
||||
esClient: core.elasticsearch.dataClient,
|
||||
config: currentConfig,
|
||||
});
|
||||
|
||||
return {
|
||||
|
@ -75,7 +69,7 @@ export class APMPlugin implements Plugin<APMPluginContract> {
|
|||
this.legacySetup$.complete();
|
||||
}),
|
||||
getApmIndices: async (savedObjectsClient: SavedObjectsClientContract) => {
|
||||
return getApmIndices({ savedObjectsClient, config: this.currentConfig });
|
||||
return getApmIndices({ savedObjectsClient, config: currentConfig });
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue