From f7d260d6777ea208536507fce3f9053f7182faec Mon Sep 17 00:00:00 2001 From: Caue Marcondes Date: Fri, 29 Sep 2023 10:13:15 +0100 Subject: [PATCH 1/3] [APM] Hidding UP tab for RUM --- .../profiling_flamegraph.tsx | 42 +++++++++++++++---- .../templates/apm_service_template/index.tsx | 5 ++- .../apm/server/routes/profiling/route.ts | 8 ++++ 3 files changed, 45 insertions(+), 10 deletions(-) diff --git a/x-pack/plugins/apm/public/components/app/profiling_overview/profiling_flamegraph.tsx b/x-pack/plugins/apm/public/components/app/profiling_overview/profiling_flamegraph.tsx index 2df8eb2e28c8b..3db934039a769 100644 --- a/x-pack/plugins/apm/public/components/app/profiling_overview/profiling_flamegraph.tsx +++ b/x-pack/plugins/apm/public/components/app/profiling_overview/profiling_flamegraph.tsx @@ -5,17 +5,28 @@ * 2.0. */ -import { EuiFlexGroup, EuiFlexItem, EuiLink, EuiSpacer } from '@elastic/eui'; +import { + EuiEmptyPrompt, + EuiFlexGroup, + EuiFlexItem, + EuiLink, + EuiSpacer, +} from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { EmbeddableFlamegraph } from '@kbn/observability-shared-plugin/public'; +import { isEmpty } from 'lodash'; import React from 'react'; +import { ApmDataSourceWithSummary } from '../../../../common/data_source'; +import { ApmDocumentType } from '../../../../common/document_type'; import { HOST_NAME } from '../../../../common/es_fields/apm'; import { toKueryFilterFormat } from '../../../../common/utils/to_kuery_filter_format'; -import { isPending, useFetcher } from '../../../hooks/use_fetcher'; +import { + FETCH_STATUS, + isPending, + useFetcher, +} from '../../../hooks/use_fetcher'; import { useProfilingPlugin } from '../../../hooks/use_profiling_plugin'; import { HostnamesFilterWarning } from './host_names_filter_warning'; -import { ApmDataSourceWithSummary } from '../../../../common/data_source'; -import { ApmDocumentType } from '../../../../common/document_type'; interface Props { serviceName: string; @@ -86,11 +97,24 @@ export function ProfilingFlamegraph({ - + {status === FETCH_STATUS.SUCCESS && isEmpty(data) ? ( + + {i18n.translate('xpack.apm.profiling.flamegraph.noDataFound', { + defaultMessage: 'No data found', + })} + + } + /> + ) : ( + + )} ); } diff --git a/x-pack/plugins/apm/public/components/routing/templates/apm_service_template/index.tsx b/x-pack/plugins/apm/public/components/routing/templates/apm_service_template/index.tsx index c797550c1617a..8cfd0292c7a2e 100644 --- a/x-pack/plugins/apm/public/components/routing/templates/apm_service_template/index.tsx +++ b/x-pack/plugins/apm/public/components/routing/templates/apm_service_template/index.tsx @@ -404,7 +404,10 @@ function useTabs({ selectedTab }: { selectedTab: Tab['key'] }) { label: i18n.translate('xpack.apm.home.profilingTabLabel', { defaultMessage: 'Universal Profiling', }), - hidden: !isProfilingAvailable, + hidden: + !isProfilingAvailable || + !isMobileAgentName(agentName) || + !isRumAgentName(agentName), append: ( {i18n.translate('xpack.apm.universalProfiling.newLabel', { diff --git a/x-pack/plugins/apm/server/routes/profiling/route.ts b/x-pack/plugins/apm/server/routes/profiling/route.ts index 78c605cb2f457..b3e0a78ea5f2d 100644 --- a/x-pack/plugins/apm/server/routes/profiling/route.ts +++ b/x-pack/plugins/apm/server/routes/profiling/route.ts @@ -57,6 +57,10 @@ const profilingFlamegraphRoute = createApmServerRoute({ rollupInterval, }); + if (!serviceHostNames.length) { + return undefined; + } + const flamegraph = await profilingDataAccessStart?.services.fetchFlamechartData({ esClient: esClient.asCurrentUser, @@ -116,6 +120,10 @@ const profilingFunctionsRoute = createApmServerRoute({ rollupInterval, }); + if (!serviceHostNames.length) { + return undefined; + } + const functions = await profilingDataAccessStart?.services.fetchFunction({ esClient: esClient.asCurrentUser, rangeFromMs: start, From 5a20c9dc565321bf13a41c64ce1c08906b893ff4 Mon Sep 17 00:00:00 2001 From: Caue Marcondes Date: Fri, 29 Sep 2023 10:26:51 +0100 Subject: [PATCH 2/3] addressing pr comments --- .../routing/templates/apm_service_template/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/apm/public/components/routing/templates/apm_service_template/index.tsx b/x-pack/plugins/apm/public/components/routing/templates/apm_service_template/index.tsx index 8cfd0292c7a2e..018af97c03d98 100644 --- a/x-pack/plugins/apm/public/components/routing/templates/apm_service_template/index.tsx +++ b/x-pack/plugins/apm/public/components/routing/templates/apm_service_template/index.tsx @@ -406,8 +406,8 @@ function useTabs({ selectedTab }: { selectedTab: Tab['key'] }) { }), hidden: !isProfilingAvailable || - !isMobileAgentName(agentName) || - !isRumAgentName(agentName), + isMobileAgentName(agentName) || + isRumAgentName(agentName), append: ( {i18n.translate('xpack.apm.universalProfiling.newLabel', { From 364f93058135ded76d0c026d742b38afdc6bac1d Mon Sep 17 00:00:00 2001 From: Caue Marcondes Date: Fri, 29 Sep 2023 10:46:43 +0100 Subject: [PATCH 3/3] adressing pr comments --- .../routing/templates/apm_service_template/index.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/apm/public/components/routing/templates/apm_service_template/index.tsx b/x-pack/plugins/apm/public/components/routing/templates/apm_service_template/index.tsx index 018af97c03d98..2e97a0e6156c5 100644 --- a/x-pack/plugins/apm/public/components/routing/templates/apm_service_template/index.tsx +++ b/x-pack/plugins/apm/public/components/routing/templates/apm_service_template/index.tsx @@ -27,6 +27,7 @@ import { isAWSLambdaAgent, isAzureFunctionsAgent, isServerlessAgent, + isRumOrMobileAgent, } from '../../../../../common/agent_name'; import { useApmPluginContext } from '../../../../context/apm_plugin/use_apm_plugin_context'; import { ApmServiceContextProvider } from '../../../../context/apm_service/apm_service_context'; @@ -406,8 +407,8 @@ function useTabs({ selectedTab }: { selectedTab: Tab['key'] }) { }), hidden: !isProfilingAvailable || - isMobileAgentName(agentName) || - isRumAgentName(agentName), + isRumOrMobileAgent(agentName) || + isAWSLambdaAgent(serverlessType), append: ( {i18n.translate('xpack.apm.universalProfiling.newLabel', {