From 4295dfec0f745761edb3de64e2fe18abff253bb9 Mon Sep 17 00:00:00 2001 From: spalger Date: Sat, 13 Jun 2020 14:37:30 -0700 Subject: [PATCH 1/3] skip flaky suite (#63339) --- x-pack/test/functional/apps/canvas/custom_elements.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x-pack/test/functional/apps/canvas/custom_elements.ts b/x-pack/test/functional/apps/canvas/custom_elements.ts index 029837ad6ef0..20ad045d0a65 100644 --- a/x-pack/test/functional/apps/canvas/custom_elements.ts +++ b/x-pack/test/functional/apps/canvas/custom_elements.ts @@ -19,7 +19,8 @@ export default function canvasCustomElementTest({ const PageObjects = getPageObjects(['canvas', 'common']); const find = getService('find'); - describe('custom elements', function () { + // FLAKY: https://github.com/elastic/kibana/issues/63339 + describe.skip('custom elements', function () { this.tags('skipFirefox'); before(async () => { From 4ce3702a8477efb1dff5e7e3748fe5b46ecdc36b Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Mon, 15 Jun 2020 08:44:24 +0200 Subject: [PATCH 2/3] Rename space id for disabled index pattern test (#68990) --- .../apps/discover/feature_controls/discover_spaces.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/x-pack/test/functional/apps/discover/feature_controls/discover_spaces.ts b/x-pack/test/functional/apps/discover/feature_controls/discover_spaces.ts index 96a601a57633..767dad74c23d 100644 --- a/x-pack/test/functional/apps/discover/feature_controls/discover_spaces.ts +++ b/x-pack/test/functional/apps/discover/feature_controls/discover_spaces.ts @@ -140,19 +140,19 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('space with index pattern management disabled', () => { before(async () => { await spacesService.create({ - id: 'custom_space', - name: 'custom_space', + id: 'custom_space_no_index_patterns', + name: 'custom_space_no_index_patterns', disabledFeatures: ['indexPatterns'], }); }); after(async () => { - await spacesService.delete('custom_space'); + await spacesService.delete('custom_space_no_index_patterns'); }); it('Navigates to Kibana home rather than index pattern management when no index patterns exist', async () => { await PageObjects.common.navigateToUrl('discover', '', { - basePath: '/s/custom_space', + basePath: '/s/custom_space_no_index_patterns', ensureCurrentUrl: false, }); await testSubjects.existOrFail('homeApp', { timeout: config.get('timeouts.waitFor') }); From 437f9f6041e067ecdc77f3f6cd622f52ef51a719 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Marcondes?= <55978943+cauemarcondes@users.noreply.github.com> Date: Mon, 15 Jun 2020 07:46:36 +0100 Subject: [PATCH 3/3] [Observability] Create context container to enable Observability plugin registry function (#68642) * creating observability context registry * adding registryContext * addressing PR comments * addressing PR comments * adding context to registry provider * adding obs own registry * refactoring * refactoring * fixing types * removing apm code Co-authored-by: Elastic Machine --- x-pack/plugins/apm/public/plugin.ts | 7 ++-- .../observability/public/data_handler.ts | 24 +++++++++++ .../public/hooks/use_track_metric.tsx | 3 +- x-pack/plugins/observability/public/index.ts | 6 ++- x-pack/plugins/observability/public/plugin.ts | 16 +++++-- .../public/typings/data_handler/index.d.ts | 42 +++++++++++++++++++ .../plugins/observability/typings/common.ts | 2 + 7 files changed, 89 insertions(+), 11 deletions(-) create mode 100644 x-pack/plugins/observability/public/data_handler.ts create mode 100644 x-pack/plugins/observability/public/typings/data_handler/index.d.ts diff --git a/x-pack/plugins/apm/public/plugin.ts b/x-pack/plugins/apm/public/plugin.ts index 2f46e2090351..e9de8fcd890d 100644 --- a/x-pack/plugins/apm/public/plugin.ts +++ b/x-pack/plugins/apm/public/plugin.ts @@ -7,6 +7,7 @@ import { i18n } from '@kbn/i18n'; import { lazy } from 'react'; import { ConfigSchema } from '.'; +import { ObservabilityPluginSetup } from '../../observability/public'; import { AppMountParameters, CoreSetup, @@ -33,10 +34,10 @@ import { import { AlertType } from '../common/alert_types'; import { featureCatalogueEntry } from './featureCatalogueEntry'; import { createCallApmApi } from './services/rest/createCallApmApi'; -import { createStaticIndexPattern } from './services/rest/index_pattern'; import { setHelpExtension } from './setHelpExtension'; import { toggleAppLinkInNav } from './toggleAppLinkInNav'; import { setReadonlyBadge } from './updateBadge'; +import { createStaticIndexPattern } from './services/rest/index_pattern'; export type ApmPluginSetup = void; export type ApmPluginStart = void; @@ -48,6 +49,7 @@ export interface ApmPluginSetupDeps { home: HomePublicPluginSetup; licensing: LicensingPluginSetup; triggers_actions_ui: TriggersAndActionsUIPublicPluginSetup; + observability?: ObservabilityPluginSetup; } export interface ApmPluginStartDeps { @@ -64,6 +66,7 @@ export class ApmPlugin implements Plugin { this.initializerContext = initializerContext; } public setup(core: CoreSetup, plugins: ApmPluginSetupDeps) { + createCallApmApi(core.http); const config = this.initializerContext.config.get(); const pluginSetupDeps = plugins; @@ -100,8 +103,6 @@ export class ApmPlugin implements Plugin { }); } public start(core: CoreStart, plugins: ApmPluginStartDeps) { - createCallApmApi(core.http); - toggleAppLinkInNav(core, this.initializerContext.config.get()); plugins.triggers_actions_ui.alertTypeRegistry.register({ diff --git a/x-pack/plugins/observability/public/data_handler.ts b/x-pack/plugins/observability/public/data_handler.ts new file mode 100644 index 000000000000..30a7357404d2 --- /dev/null +++ b/x-pack/plugins/observability/public/data_handler.ts @@ -0,0 +1,24 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { FetchData, HasData } from './typings/data_handler'; +import { ObservabilityApp } from '../typings/common'; + +interface DataHandler { + fetchData: FetchData; + hasData: HasData; +} + +const dataHandlers: Partial> = {}; + +export type RegisterDataHandler = (params: { appName: ObservabilityApp } & DataHandler) => void; +export const registerDataHandler: RegisterDataHandler = ({ appName, fetchData, hasData }) => { + dataHandlers[appName] = { fetchData, hasData }; +}; + +export function getDataHandler(appName: ObservabilityApp): DataHandler | undefined { + return dataHandlers[appName]; +} diff --git a/x-pack/plugins/observability/public/hooks/use_track_metric.tsx b/x-pack/plugins/observability/public/hooks/use_track_metric.tsx index b146a80e89ea..2c7ce8cbabf8 100644 --- a/x-pack/plugins/observability/public/hooks/use_track_metric.tsx +++ b/x-pack/plugins/observability/public/hooks/use_track_metric.tsx @@ -8,6 +8,7 @@ import { useEffect, useMemo } from 'react'; import { METRIC_TYPE, UiStatsMetricType } from '@kbn/analytics'; import { UsageCollectionSetup } from 'src/plugins/usage_collection/public'; import { useKibana } from '../../../../../src/plugins/kibana_react/public'; +import { ObservabilityApp } from '../../typings/common'; /** * Note: The usage_collection plugin will take care of sending this data to the telemetry server. @@ -17,8 +18,6 @@ import { useKibana } from '../../../../../src/plugins/kibana_react/public'; * a value, which will be a counter */ -type ObservabilityApp = 'infra_metrics' | 'infra_logs' | 'apm' | 'uptime'; - interface TrackOptions { app?: ObservabilityApp; metricType?: UiStatsMetricType; diff --git a/x-pack/plugins/observability/public/index.ts b/x-pack/plugins/observability/public/index.ts index dd8bca90cff4..ade347c79728 100644 --- a/x-pack/plugins/observability/public/index.ts +++ b/x-pack/plugins/observability/public/index.ts @@ -5,14 +5,16 @@ */ import { PluginInitializerContext, PluginInitializer } from 'kibana/public'; -import { Plugin, ClientSetup, ClientStart } from './plugin'; +import { Plugin, ObservabilityPluginSetup, ObservabilityPluginStart } from './plugin'; -export const plugin: PluginInitializer = ( +export const plugin: PluginInitializer = ( context: PluginInitializerContext ) => { return new Plugin(context); }; +export { ObservabilityPluginSetup, ObservabilityPluginStart }; + export * from './components/action_menu'; export { diff --git a/x-pack/plugins/observability/public/plugin.ts b/x-pack/plugins/observability/public/plugin.ts index f2c88a7b1c05..16adf88d152c 100644 --- a/x-pack/plugins/observability/public/plugin.ts +++ b/x-pack/plugins/observability/public/plugin.ts @@ -10,11 +10,15 @@ import { Plugin as PluginClass, PluginInitializerContext, } from '../../../../src/core/public'; +import { RegisterDataHandler, registerDataHandler } from './data_handler'; -export type ClientSetup = void; -export type ClientStart = void; +export interface ObservabilityPluginSetup { + dashboard: { register: RegisterDataHandler }; +} + +export type ObservabilityPluginStart = void; -export class Plugin implements PluginClass { +export class Plugin implements PluginClass { constructor(context: PluginInitializerContext) {} public setup(core: CoreSetup) { @@ -25,7 +29,7 @@ export class Plugin implements PluginClass { appRoute: '/app/observability', category: DEFAULT_APP_CATEGORIES.observability, - async mount(params: AppMountParameters) { + mount: async (params: AppMountParameters) => { // Load application bundle const { renderApp } = await import('./application'); // Get start services @@ -34,6 +38,10 @@ export class Plugin implements PluginClass { return renderApp(coreStart, params); }, }); + + return { + dashboard: { register: registerDataHandler }, + }; } public start() {} } diff --git a/x-pack/plugins/observability/public/typings/data_handler/index.d.ts b/x-pack/plugins/observability/public/typings/data_handler/index.d.ts new file mode 100644 index 000000000000..a208e4e7c223 --- /dev/null +++ b/x-pack/plugins/observability/public/typings/data_handler/index.d.ts @@ -0,0 +1,42 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +interface Stat { + label: string; + value: string; + color?: string; +} + +export interface Coordinates { + x: number; + y?: number; +} + +interface Series { + label: string; + coordinates: Coordinates[]; + color?: string; + key?: string; +} + +interface FetchDataResponse { + title: string; + appLink: string; + stats: Stat[]; + series: Series[]; +} +interface FetchDataParams { + // The start timestamp in milliseconds of the queried time interval + startTime: string; + // The end timestamp in milliseconds of the queried time interval + endTime: string; + // The aggregation bucket size in milliseconds if applicable to the data source + bucketSize: string; +} + +export type FetchData = (fetchDataParams: FetchDataParams) => Promise; + +export type HasData = () => Promise; diff --git a/x-pack/plugins/observability/typings/common.ts b/x-pack/plugins/observability/typings/common.ts index b4a90934a9f4..579c4fe3bbb9 100644 --- a/x-pack/plugins/observability/typings/common.ts +++ b/x-pack/plugins/observability/typings/common.ts @@ -4,6 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ +export type ObservabilityApp = 'infra_metrics' | 'infra_logs' | 'apm' | 'uptime'; + export type PromiseReturnType = Func extends (...args: any[]) => Promise ? Value : Func;