From 2f2be9acf454b630fa2ea80a75f712ab925c23db Mon Sep 17 00:00:00 2001 From: Carlos Crespo Date: Mon, 3 Mar 2025 11:54:50 +0100 Subject: [PATCH] change to enable the new api on the kibana config --- .../settings/setting_ids/index.ts | 1 - .../settings/observability_project/index.ts | 1 - .../server/collectors/management/schema.ts | 4 --- .../server/collectors/management/types.ts | 1 - .../service_map/get_service_map_nodes.ts | 2 -- .../app/settings/general_settings/index.tsx | 2 -- .../observability/plugins/apm/server/index.ts | 1 + .../routes/service_map/get_service_map.ts | 14 +++++++-- .../apm/server/routes/service_map/route.ts | 30 ++++++++----------- .../plugins/apm/server/routes/typings.ts | 1 - .../plugins/observability/common/index.ts | 1 - .../observability/common/ui_settings_keys.ts | 1 - .../observability/server/ui_settings.ts | 18 ----------- 13 files changed, 24 insertions(+), 53 deletions(-) diff --git a/src/platform/packages/shared/kbn-management/settings/setting_ids/index.ts b/src/platform/packages/shared/kbn-management/settings/setting_ids/index.ts index f999629b46189..0879cad21b804 100644 --- a/src/platform/packages/shared/kbn-management/settings/setting_ids/index.ts +++ b/src/platform/packages/shared/kbn-management/settings/setting_ids/index.ts @@ -130,7 +130,6 @@ export const OBSERVABILITY_APM_ENABLE_CONTINUOUS_ROLLUPS_ID = export const OBSERVABILITY_APM_ENABLE_PROFILING_INTEGRATION_ID = 'observability:apmEnableProfilingIntegration'; export const OBSERVABILITY_APM_ENABLE_TABLE_SEARCH_BAR = 'observability:apmEnableTableSearchBar'; -export const OBSERVABILITY_APM_ENABLE_SERVICE_MAP_V2 = 'observability:apmEnableServiceMapV2'; export const OBSERVABILITY_APM_ENABLE_SERVICE_INVENTORY_TABLE_SEARCH_BAR = 'observability:apmEnableServiceInventoryTableSearchBar'; export const OBSERVABILITY_LOGS_SHARED_NEW_LOGS_OVERVIEW_ID = 'observability:newLogsOverview'; diff --git a/src/platform/packages/shared/serverless/settings/observability_project/index.ts b/src/platform/packages/shared/serverless/settings/observability_project/index.ts index 250f10cc21216..2b0ab1e3638b3 100644 --- a/src/platform/packages/shared/serverless/settings/observability_project/index.ts +++ b/src/platform/packages/shared/serverless/settings/observability_project/index.ts @@ -29,7 +29,6 @@ export const OBSERVABILITY_PROJECT_SETTINGS = [ settings.OBSERVABILITY_APM_ENABLE_CRITICAL_PATH_ID, settings.OBSERVABILITY_ENABLE_INFRASTRUCTURE_ASSET_CUSTOM_DASHBOARDS_ID, settings.OBSERVABILITY_APM_ENABLE_TABLE_SEARCH_BAR, - settings.OBSERVABILITY_APM_ENABLE_SERVICE_MAP_V2, settings.OBSERVABILITY_APM_ENABLE_SERVICE_INVENTORY_TABLE_SEARCH_BAR, settings.OBSERVABILITY_ENTITY_CENTRIC_EXPERIENCE, settings.OBSERVABILITY_AI_ASSISTANT_SIMULATED_FUNCTION_CALLING, diff --git a/src/platform/plugins/private/kibana_usage_collection/server/collectors/management/schema.ts b/src/platform/plugins/private/kibana_usage_collection/server/collectors/management/schema.ts index 08e530788237d..5d988c516136b 100644 --- a/src/platform/plugins/private/kibana_usage_collection/server/collectors/management/schema.ts +++ b/src/platform/plugins/private/kibana_usage_collection/server/collectors/management/schema.ts @@ -472,10 +472,6 @@ export const stackManagementSchema: MakeSchemaFrom = { type: 'boolean', _meta: { description: 'Non-default value of setting.' }, }, - 'observability:apmEnableServiceMapV2': { - type: 'boolean', - _meta: { description: 'Non-default value of setting.' }, - }, 'observability:entityCentricExperience': { type: 'boolean', _meta: { description: 'Non-default value of setting.' }, diff --git a/src/platform/plugins/private/kibana_usage_collection/server/collectors/management/types.ts b/src/platform/plugins/private/kibana_usage_collection/server/collectors/management/types.ts index 874d4db228c6d..ef5e5dfebf357 100644 --- a/src/platform/plugins/private/kibana_usage_collection/server/collectors/management/types.ts +++ b/src/platform/plugins/private/kibana_usage_collection/server/collectors/management/types.ts @@ -48,7 +48,6 @@ export interface UsageStats { 'observability:enableInfrastructureAssetCustomDashboards': boolean; 'observability:apmAgentExplorerView': boolean; 'observability:apmEnableTableSearchBar': boolean; - 'observability:apmEnableServiceMapV2': boolean; 'observability:apmEnableServiceInventoryTableSearchBar': boolean; 'observability:logSources': string[]; 'observability:newLogsOverview': boolean; diff --git a/x-pack/solutions/observability/plugins/apm/common/service_map/get_service_map_nodes.ts b/x-pack/solutions/observability/plugins/apm/common/service_map/get_service_map_nodes.ts index 3f3730ef5e8cf..f35c9cb228f23 100644 --- a/x-pack/solutions/observability/plugins/apm/common/service_map/get_service_map_nodes.ts +++ b/x-pack/solutions/observability/plugins/apm/common/service_map/get_service_map_nodes.ts @@ -34,7 +34,6 @@ function addMessagingConnections( connections: Connection[], destinationServices: ExitSpanDestination[] ): Connection[] { - // Index discoveredServices by SPAN_DESTINATION_SERVICE_RESOURCE for quick lookups const serviceMap = new Map( destinationServices.map(({ from, to }) => [from[SPAN_DESTINATION_SERVICE_RESOURCE], to]) ); @@ -59,7 +58,6 @@ function addMessagingConnections( function getAllNodes(services: ServicesResponse[], connections: Connection[]) { const allNodesMap = new Map(); - // Process connections in one pass connections.forEach((connection) => { const sourceId = connection.source.id; const destinationId = connection.destination.id; diff --git a/x-pack/solutions/observability/plugins/apm/public/components/app/settings/general_settings/index.tsx b/x-pack/solutions/observability/plugins/apm/public/components/app/settings/general_settings/index.tsx index 33c38796b5227..053cba1b1f7a2 100644 --- a/x-pack/solutions/observability/plugins/apm/public/components/app/settings/general_settings/index.tsx +++ b/x-pack/solutions/observability/plugins/apm/public/components/app/settings/general_settings/index.tsx @@ -23,7 +23,6 @@ import { apmEnableTableSearchBar, apmEnableTransactionProfiling, apmEnableServiceInventoryTableSearchBar, - apmEnableServiceMapV2, } from '@kbn/observability-plugin/common'; import { isEmpty } from 'lodash'; import React from 'react'; @@ -57,7 +56,6 @@ function getApmSettingsKeys(isProfilingIntegrationEnabled: boolean) { enableAgentExplorerView, apmEnableTableSearchBar, apmEnableServiceInventoryTableSearchBar, - apmEnableServiceMapV2, ]; if (isProfilingIntegrationEnabled) { diff --git a/x-pack/solutions/observability/plugins/apm/server/index.ts b/x-pack/solutions/observability/plugins/apm/server/index.ts index a37f453e7112a..02f0f6021bea1 100644 --- a/x-pack/solutions/observability/plugins/apm/server/index.ts +++ b/x-pack/solutions/observability/plugins/apm/server/index.ts @@ -32,6 +32,7 @@ const configSchema = schema.object({ serviceMapTraceIdGlobalBucketSize: schema.number({ defaultValue: 6 }), serviceMapMaxTracesPerRequest: schema.number({ defaultValue: 50 }), serviceMapTerminateAfter: schema.number({ defaultValue: 100_000 }), + serviceMapV2Enabled: schema.boolean({ defaultValue: false }), serviceMapMaxTraces: schema.number({ defaultValue: 1000 }), ui: schema.object({ enabled: schema.boolean({ defaultValue: true }), diff --git a/x-pack/solutions/observability/plugins/apm/server/routes/service_map/get_service_map.ts b/x-pack/solutions/observability/plugins/apm/server/routes/service_map/get_service_map.ts index 3aa26f3349f39..3cde1ed41913f 100644 --- a/x-pack/solutions/observability/plugins/apm/server/routes/service_map/get_service_map.ts +++ b/x-pack/solutions/observability/plugins/apm/server/routes/service_map/get_service_map.ts @@ -35,7 +35,6 @@ export interface IEnvOptions { end: number; serviceGroupKuery?: string; kuery?: string; - serviceMapV2Enabled?: boolean; } async function getConnectionData({ @@ -48,7 +47,6 @@ async function getConnectionData({ serviceGroupKuery, kuery, logger, - serviceMapV2Enabled = false, }: IEnvOptions): Promise< { tracesCount: number } & ( | { connections: Connection[]; discoveredServices: ExitSpanDestination[] } @@ -70,7 +68,7 @@ async function getConnectionData({ logger.debug(`Found ${traceIds.length} traces to inspect`); - if (serviceMapV2Enabled) { + if (config.serviceMapV2Enabled) { const spans = await withApmSpan( 'get_service_map_exit_spans_and_transactions_from_traces', () => @@ -88,8 +86,18 @@ async function getConnectionData({ }; } + if (!traceIds.length) { + return { + connections: [], + discoveredServices: [], + tracesCount: 0, + }; + } + const chunkedResponses = await withApmSpan('get_service_paths_from_all_trace_ids', () => { const chunks = chunk(traceIds, config.serviceMapMaxTracesPerRequest); + logger.debug(`Executing scripted metric agg (${chunks.length} chunks)`); + return Promise.all( chunks.map((traceIdsChunk) => getServiceMapFromTraceIds({ diff --git a/x-pack/solutions/observability/plugins/apm/server/routes/service_map/route.ts b/x-pack/solutions/observability/plugins/apm/server/routes/service_map/route.ts index 1c0b237961100..646e42db946f8 100644 --- a/x-pack/solutions/observability/plugins/apm/server/routes/service_map/route.ts +++ b/x-pack/solutions/observability/plugins/apm/server/routes/service_map/route.ts @@ -7,10 +7,7 @@ import Boom from '@hapi/boom'; import * as t from 'io-ts'; -import { - apmEnableServiceMapV2, - apmServiceGroupMaxNumberOfServices, -} from '@kbn/observability-plugin/common'; +import { apmServiceGroupMaxNumberOfServices } from '@kbn/observability-plugin/common'; import type { ServiceMapResponse } from '../../../common/service_map'; import { isActivePlatinumLicense } from '../../../common/license_check'; import { invalidLicenseMessage } from '../../../common/service_map/utils'; @@ -67,19 +64,17 @@ const serviceMapRoute = createApmServerRoute({ uiSettings: { client: uiSettingsClient }, } = await context.core; - const [mlClient, apmEventClient, serviceGroup, maxNumberOfServices, serviceMapV2Enabled] = - await Promise.all([ - getMlClient(resources), - getApmEventClient(resources), - serviceGroupId - ? getServiceGroup({ - savedObjectsClient, - serviceGroupId, - }) - : Promise.resolve(null), - uiSettingsClient.get(apmServiceGroupMaxNumberOfServices), - uiSettingsClient.get(apmEnableServiceMapV2), - ]); + const [mlClient, apmEventClient, serviceGroup, maxNumberOfServices] = await Promise.all([ + getMlClient(resources), + getApmEventClient(resources), + serviceGroupId + ? getServiceGroup({ + savedObjectsClient, + serviceGroupId, + }) + : Promise.resolve(null), + uiSettingsClient.get(apmServiceGroupMaxNumberOfServices), + ]); const searchAggregatedTransactions = await getSearchTransactionsEvents({ apmEventClient, @@ -102,7 +97,6 @@ const serviceMapRoute = createApmServerRoute({ maxNumberOfServices, serviceGroupKuery: serviceGroup?.kuery, kuery, - serviceMapV2Enabled, }); }, }); diff --git a/x-pack/solutions/observability/plugins/apm/server/routes/typings.ts b/x-pack/solutions/observability/plugins/apm/server/routes/typings.ts index 05c408a2e376c..117fd820f3e3a 100644 --- a/x-pack/solutions/observability/plugins/apm/server/routes/typings.ts +++ b/x-pack/solutions/observability/plugins/apm/server/routes/typings.ts @@ -47,7 +47,6 @@ export type MinimalApmPluginRequestHandlerContext = Omit< export interface APMRouteCreateOptions { tags?: Array<'oas-tag:APM agent keys' | 'oas-tag:APM annotations'>; disableTelemetry?: boolean; - stream?: boolean; } export type TelemetryUsageCounter = ReturnType; diff --git a/x-pack/solutions/observability/plugins/observability/common/index.ts b/x-pack/solutions/observability/plugins/observability/common/index.ts index 7231dfde3e3c8..327e6729426ce 100644 --- a/x-pack/solutions/observability/plugins/observability/common/index.ts +++ b/x-pack/solutions/observability/plugins/observability/common/index.ts @@ -34,7 +34,6 @@ export { enableInfrastructureAssetCustomDashboards, enableAwsLambdaMetrics, enableAgentExplorerView, - apmEnableServiceMapV2, apmEnableTableSearchBar, entityCentricExperience, apmAWSLambdaPriceFactor, diff --git a/x-pack/solutions/observability/plugins/observability/common/ui_settings_keys.ts b/x-pack/solutions/observability/plugins/observability/common/ui_settings_keys.ts index 5c29479c760c7..7025c120cae5d 100644 --- a/x-pack/solutions/observability/plugins/observability/common/ui_settings_keys.ts +++ b/x-pack/solutions/observability/plugins/observability/common/ui_settings_keys.ts @@ -23,7 +23,6 @@ export const enableInfrastructureAssetCustomDashboards = export const enableAwsLambdaMetrics = 'observability:enableAwsLambdaMetrics'; export const enableAgentExplorerView = 'observability:apmAgentExplorerView'; export const apmEnableTableSearchBar = 'observability:apmEnableTableSearchBar'; -export const apmEnableServiceMapV2 = 'observability:apmEnableServiceMapV2'; export const entityCentricExperience = 'observability:entityCentricExperience'; export const apmEnableServiceInventoryTableSearchBar = 'observability:apmEnableServiceInventoryTableSearchBar'; diff --git a/x-pack/solutions/observability/plugins/observability/server/ui_settings.ts b/x-pack/solutions/observability/plugins/observability/server/ui_settings.ts index 2ff8c36cd6338..ed79e7e66787e 100644 --- a/x-pack/solutions/observability/plugins/observability/server/ui_settings.ts +++ b/x-pack/solutions/observability/plugins/observability/server/ui_settings.ts @@ -45,7 +45,6 @@ import { apmEnableServiceInventoryTableSearchBar, profilingFetchTopNFunctionsFromStacktraces, searchExcludedDataTiers, - apmEnableServiceMapV2, } from '../common/ui_settings_keys'; const betaLabel = i18n.translate('xpack.observability.uiSettings.betaLabel', { @@ -366,23 +365,6 @@ export const uiSettings: Record = { type: 'boolean', solution: 'oblt', }, - [apmEnableServiceMapV2]: { - category: [observabilityFeatureId], - name: i18n.translate('xpack.observability.apmEnableServiceMapV2', { - defaultMessage: 'Service Map API V2', - }), - description: i18n.translate('xpack.observability.apmEnableServiceMapV2Description', { - defaultMessage: '{technicalPreviewLabel} Enables the new service map API.', - values: { - technicalPreviewLabel: `[${technicalPreviewLabel}]`, - }, - }), - schema: schema.boolean(), - value: false, - requiresPageReload: false, - type: 'boolean', - solution: 'oblt', - }, [apmAWSLambdaPriceFactor]: { category: [observabilityFeatureId], name: i18n.translate('xpack.observability.apmAWSLambdaPricePerGbSeconds', {