Skip to content

Commit

Permalink
[7.8] Move apm tutorial from apm plugin into apm_oss plugin (#66432) (#…
Browse files Browse the repository at this point in the history
…67619)

* Move apm tutorial from apm plugin into apm_oss plugin (#66432)

* Move apm tutorial from apm plugin into apm_oss plugin

Closes #65629

* Fix types issues and some paths

* Add unregisterTutorial to tutorials_registry.mock

* Add apm path to .i18nrc.json to fix internationalization error

* Rename apm path in .i18nrc.json into apmOss and revert some imports paths
# Conflicts:
#	x-pack/plugins/apm/server/plugin.ts
#	x-pack/plugins/apm/server/tutorial/elastic_cloud.ts
#	x-pack/plugins/apm/server/tutorial/envs/on_prem.ts
#	x-pack/plugins/apm/server/tutorial/index.ts
#	x-pack/plugins/apm/server/tutorial/instructions/apm_agent_instructions.ts
#	x-pack/plugins/apm/server/tutorial/instructions/apm_server_instructions.ts
#	x-pack/plugins/translations/translations/ja-JP.json
#	x-pack/plugins/translations/translations/zh-CN.json

* Fix issues produced by mistake through merge conflict

* Fix some eslint issues

* Fix type check

* Remove unused translations
  • Loading branch information
DianaDerevyankina committed Jun 2, 2020
1 parent 301372e commit 3fc974b
Show file tree
Hide file tree
Showing 26 changed files with 1,273 additions and 1,325 deletions.
3 changes: 2 additions & 1 deletion .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
"visTypeVislib": "src/plugins/vis_type_vislib",
"visTypeXy": "src/plugins/vis_type_xy",
"visualizations": "src/plugins/visualizations",
"visualize": "src/plugins/visualize"
"visualize": "src/plugins/visualize",
"apmOss": "src/plugins/apm_oss"
},
"exclude": [
"src/legacy/ui/ui_render/ui_render_mixin.js"
Expand Down
20 changes: 20 additions & 0 deletions src/plugins/apm_oss/common/index_pattern_constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

export const APM_STATIC_INDEX_PATTERN_ID = 'apm_static_index_pattern_id';
4 changes: 2 additions & 2 deletions src/plugins/apm_oss/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"configPath": [
"apm_oss"
],
"ui": false,
"requiredPlugins": []
"ui": true,
"requiredPlugins": ["home"]
}
File renamed without changes
29 changes: 29 additions & 0 deletions src/plugins/apm_oss/public/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { ApmOssPlugin } from './plugin';

// This exports static code and TypeScript types,
// as well as, Kibana Platform `plugin()` initializer.
export function plugin() {
return new ApmOssPlugin();
}
export { ApmOssPluginSetup, ApmOssPluginStart } from './types';

export { APM_STATIC_INDEX_PATTERN_ID } from '../common/index_pattern_constants';
33 changes: 33 additions & 0 deletions src/plugins/apm_oss/public/plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { CoreSetup, CoreStart, Plugin } from 'kibana/public';
import { ApmOssPluginSetup, ApmOssPluginStart } from './types';

export class ApmOssPlugin implements Plugin<ApmOssPluginSetup, ApmOssPluginStart> {
public setup(core: CoreSetup): ApmOssPluginSetup {
return {};
}

public start(core: CoreStart): ApmOssPluginStart {
return {};
}

public stop() {}
}
27 changes: 27 additions & 0 deletions src/plugins/apm_oss/public/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface ApmOssPluginSetup {}

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface ApmOssPluginStart {}

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface AppPluginStartDependencies {}
15 changes: 15 additions & 0 deletions src/plugins/apm_oss/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

import { schema, TypeOf } from '@kbn/config-schema';
import apmIndexPattern from './tutorial/index_pattern.json';
import { PluginInitializerContext } from '../../../core/server';
import { APMOSSPlugin } from './plugin';

Expand All @@ -41,3 +42,17 @@ export function plugin(initializerContext: PluginInitializerContext) {
export type APMOSSConfig = TypeOf<typeof config.schema>;

export { APMOSSPluginSetup } from './plugin';

export { apmIndexPattern };

export {
createNodeAgentInstructions,
createDjangoAgentInstructions,
createFlaskAgentInstructions,
createRailsAgentInstructions,
createRackAgentInstructions,
createJsAgentInstructions,
createGoAgentInstructions,
createJavaAgentInstructions,
createDotNetAgentInstructions,
} from './tutorial/instructions/apm_agent_instructions';
1 change: 1 addition & 0 deletions src/plugins/apm_oss/server/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const apmOSSPluginSetupMock = {
create(config: Partial<APMOSSConfig> = {}): APMOSSPluginSetup {
return {
config$: of({ ...defaultConfig, ...config }),
getRegisteredTutorialProvider: jest.fn(),
};
},
};
22 changes: 20 additions & 2 deletions src/plugins/apm_oss/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,35 @@
*/
import { Plugin, CoreSetup, PluginInitializerContext } from 'src/core/server';
import { Observable } from 'rxjs';
import { take } from 'rxjs/operators';
import { APMOSSConfig } from './';
import { HomeServerPluginSetup, TutorialProvider } from '../../home/server';
import { tutorialProvider } from './tutorial';

export class APMOSSPlugin implements Plugin<APMOSSPluginSetup> {
constructor(private readonly initContext: PluginInitializerContext) {
this.initContext = initContext;
}

public setup(core: CoreSetup) {
public async setup(core: CoreSetup, plugins: { home: HomeServerPluginSetup }) {
const config$ = this.initContext.config.create<APMOSSConfig>();

const config = await config$.pipe(take(1)).toPromise();

const apmTutorialProvider = tutorialProvider({
indexPatternTitle: config.indexPattern,
indices: {
errorIndices: config.errorIndices,
metricsIndices: config.metricsIndices,
onboardingIndices: config.onboardingIndices,
sourcemapIndices: config.sourcemapIndices,
transactionIndices: config.transactionIndices,
},
});
plugins.home.tutorials.registerTutorial(apmTutorialProvider);

return {
config$,
getRegisteredTutorialProvider: () => apmTutorialProvider,
};
}

Expand All @@ -39,4 +56,5 @@ export class APMOSSPlugin implements Plugin<APMOSSPluginSetup> {

export interface APMOSSPluginSetup {
config$: Observable<APMOSSConfig>;
getRegisteredTutorialProvider(): TutorialProvider;
}
Loading

0 comments on commit 3fc974b

Please sign in to comment.