From 309666acc2d4f69b590631ca9bd443352e472948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Marcondes?= <55978943+cauemarcondes@users.noreply.github.com> Date: Mon, 14 Aug 2023 18:49:59 +0100 Subject: [PATCH] [APM][Profiling] Adding feature flag to enable profiling integration (#163823) Screenshot 2023-08-14 at 3 11 13 PM When Profiling is initiated but feature flag is not enabled: Screenshot 2023-08-14 at 3 17 14 PM When Profiling is initiated and feature flag is enabled: Screenshot 2023-08-14 at 3 18 59 PM --- .../server/collectors/management/schema.ts | 4 ++++ .../server/collectors/management/types.ts | 1 + src/plugins/telemetry/schema/oss_plugins.json | 6 ++++++ .../app/settings/general_settings/index.tsx | 2 ++ .../apm/public/hooks/use_profiling_plugin.tsx | 15 +++++++++++---- x-pack/plugins/observability/common/index.ts | 1 + .../observability/common/ui_settings_keys.ts | 1 + .../plugins/observability/server/ui_settings.ts | 10 ++++++++++ 8 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/plugins/kibana_usage_collection/server/collectors/management/schema.ts b/src/plugins/kibana_usage_collection/server/collectors/management/schema.ts index 27fef2a017824..9822d2985bced 100644 --- a/src/plugins/kibana_usage_collection/server/collectors/management/schema.ts +++ b/src/plugins/kibana_usage_collection/server/collectors/management/schema.ts @@ -549,6 +549,10 @@ export const stackManagementSchema: MakeSchemaFrom = { type: 'boolean', _meta: { description: 'Non-default value of setting.' }, }, + 'observability:apmEnableProfilingIntegration': { + type: 'boolean', + _meta: { description: 'Non-default value of setting.' }, + }, 'observability:apmEnableCriticalPath': { type: 'boolean', _meta: { description: 'Non-default value of setting.' }, diff --git a/src/plugins/kibana_usage_collection/server/collectors/management/types.ts b/src/plugins/kibana_usage_collection/server/collectors/management/types.ts index 81f7b0eb957f1..1b5f84019eb7b 100644 --- a/src/plugins/kibana_usage_collection/server/collectors/management/types.ts +++ b/src/plugins/kibana_usage_collection/server/collectors/management/types.ts @@ -150,6 +150,7 @@ export interface UsageStats { 'observability:apmServiceInventoryOptimizedSorting': boolean; 'observability:apmTraceExplorerTab': boolean; 'observability:apmEnableCriticalPath': boolean; + 'observability:apmEnableProfilingIntegration': boolean; 'securitySolution:enableGroupedNav': boolean; 'securitySolution:showRelatedIntegrations': boolean; 'visualization:visualize:legacyGaugeChartsLibrary': boolean; diff --git a/src/plugins/telemetry/schema/oss_plugins.json b/src/plugins/telemetry/schema/oss_plugins.json index 00d8a96a59e0e..de4f1fae8f675 100644 --- a/src/plugins/telemetry/schema/oss_plugins.json +++ b/src/plugins/telemetry/schema/oss_plugins.json @@ -9870,6 +9870,12 @@ "description": "Non-default value of setting." } }, + "observability:apmEnableProfilingIntegration": { + "type": "boolean", + "_meta": { + "description": "Non-default value of setting." + } + }, "observability:apmEnableCriticalPath": { "type": "boolean", "_meta": { diff --git a/x-pack/plugins/apm/public/components/app/settings/general_settings/index.tsx b/x-pack/plugins/apm/public/components/app/settings/general_settings/index.tsx index a39c86be9de12..52ede89eefba4 100644 --- a/x-pack/plugins/apm/public/components/app/settings/general_settings/index.tsx +++ b/x-pack/plugins/apm/public/components/app/settings/general_settings/index.tsx @@ -19,6 +19,7 @@ import { apmEnableServiceMetrics, apmEnableContinuousRollups, enableAgentExplorerView, + apmEnableProfilingIntegration, } from '@kbn/observability-plugin/common'; import { isEmpty } from 'lodash'; import React from 'react'; @@ -37,6 +38,7 @@ const apmSettingsKeys = [ apmEnableServiceMetrics, apmEnableContinuousRollups, enableAgentExplorerView, + apmEnableProfilingIntegration, ]; export function GeneralSettings() { diff --git a/x-pack/plugins/apm/public/hooks/use_profiling_plugin.tsx b/x-pack/plugins/apm/public/hooks/use_profiling_plugin.tsx index ffa07be6bfc12..945bbc43fe3a2 100644 --- a/x-pack/plugins/apm/public/hooks/use_profiling_plugin.tsx +++ b/x-pack/plugins/apm/public/hooks/use_profiling_plugin.tsx @@ -6,10 +6,15 @@ */ import { useEffect, useState } from 'react'; +import { apmEnableProfilingIntegration } from '@kbn/observability-plugin/common'; import { useApmPluginContext } from '../context/apm_plugin/use_apm_plugin_context'; export function useProfilingPlugin() { - const { plugins } = useApmPluginContext(); + const { plugins, core } = useApmPluginContext(); + const isProfilingIntegrationEnabled = core.uiSettings.get( + apmEnableProfilingIntegration, + false + ); const [isProfilingPluginInitialized, setIsProfilingPluginInitialized] = useState(); @@ -28,8 +33,10 @@ export function useProfilingPlugin() { return { isProfilingPluginInitialized, - profilingLocators: isProfilingPluginInitialized - ? plugins.profiling?.locators - : undefined, + profilingLocators: + isProfilingIntegrationEnabled && isProfilingPluginInitialized + ? plugins.profiling?.locators + : undefined, + isProfilingIntegrationEnabled, }; } diff --git a/x-pack/plugins/observability/common/index.ts b/x-pack/plugins/observability/common/index.ts index 9459802d820db..a90240d95e054 100644 --- a/x-pack/plugins/observability/common/index.ts +++ b/x-pack/plugins/observability/common/index.ts @@ -40,6 +40,7 @@ export { apmEnableContinuousRollups, enableCriticalPath, syntheticsThrottlingEnabled, + apmEnableProfilingIntegration, } from './ui_settings_keys'; export { diff --git a/x-pack/plugins/observability/common/ui_settings_keys.ts b/x-pack/plugins/observability/common/ui_settings_keys.ts index 833b6890dba03..183e9f41030ce 100644 --- a/x-pack/plugins/observability/common/ui_settings_keys.ts +++ b/x-pack/plugins/observability/common/ui_settings_keys.ts @@ -26,3 +26,4 @@ export const apmEnableServiceMetrics = 'observability:apmEnableServiceMetrics'; export const apmEnableContinuousRollups = 'observability:apmEnableContinuousRollups'; export const syntheticsThrottlingEnabled = 'observability:syntheticsThrottlingEnabled'; export const enableLegacyUptimeApp = 'observability:enableLegacyUptimeApp'; +export const apmEnableProfilingIntegration = 'observability:apmEnableProfilingIntegration'; diff --git a/x-pack/plugins/observability/server/ui_settings.ts b/x-pack/plugins/observability/server/ui_settings.ts index 637856d91c7e9..39678758bd7e1 100644 --- a/x-pack/plugins/observability/server/ui_settings.ts +++ b/x-pack/plugins/observability/server/ui_settings.ts @@ -29,6 +29,7 @@ import { enableInfrastructureHostsView, syntheticsThrottlingEnabled, enableLegacyUptimeApp, + apmEnableProfilingIntegration, } from '../common/ui_settings_keys'; const betaLabel = i18n.translate('xpack.observability.uiSettings.betaLabel', { @@ -364,6 +365,15 @@ export const uiSettings: Record = { schema: schema.boolean(), requiresPageReload: true, }, + [apmEnableProfilingIntegration]: { + category: [observabilityFeatureId], + name: i18n.translate('xpack.observability.apmEnableProfilingIntegration', { + defaultMessage: 'Enable Universal Profiling integration in APM', + }), + value: false, + schema: schema.boolean(), + requiresPageReload: false, + }, }; function throttlingDocsLink({ href }: { href: string }) {