[APM] Hidding UP tab for RUM (#167608)

<img width="900" alt="Screenshot 2023-09-29 at 10 12 24"
src="f7d97f43-df92-427d-a619-0b61601eccc7">
<img width="1537" alt="Screenshot 2023-09-29 at 10 12 30"
src="00e2844b-9d24-461a-a47a-5cbc483148af">
This commit is contained in:
Cauê Marcondes 2023-09-29 16:48:22 +01:00 committed by GitHub
parent a81b620a41
commit aa065b710c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 12 deletions

View file

@ -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 { HOST_NAME } from '../../../../common/es_fields/apm';
import { toKueryFilterFormat } from '../../../../common/utils/to_kuery_filter_format';
import { 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';
import { HOST_NAME } from '../../../../common/es_fields/apm';
import { toKueryFilterFormat } from '../../../../common/utils/to_kuery_filter_format';
import {
FETCH_STATUS,
isPending,
useFetcher,
} from '../../../hooks/use_fetcher';
import { useProfilingPlugin } from '../../../hooks/use_profiling_plugin';
import { HostnamesFilterWarning } from './host_names_filter_warning';
interface Props {
serviceName: string;
@ -86,11 +97,24 @@ export function ProfilingFlamegraph({
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer />
<EmbeddableFlamegraph
data={data?.flamegraph}
isLoading={isPending(status)}
height="60vh"
/>
{status === FETCH_STATUS.SUCCESS && isEmpty(data) ? (
<EuiEmptyPrompt
titleSize="s"
title={
<div>
{i18n.translate('xpack.apm.profiling.flamegraph.noDataFound', {
defaultMessage: 'No data found',
})}
</div>
}
/>
) : (
<EmbeddableFlamegraph
data={data?.flamegraph}
isLoading={isPending(status)}
height="60vh"
/>
)}
</>
);
}

View file

@ -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';
@ -404,7 +405,10 @@ function useTabs({ selectedTab }: { selectedTab: Tab['key'] }) {
label: i18n.translate('xpack.apm.home.profilingTabLabel', {
defaultMessage: 'Universal Profiling',
}),
hidden: !isProfilingAvailable,
hidden:
!isProfilingAvailable ||
isRumOrMobileAgent(agentName) ||
isAWSLambdaAgent(serverlessType),
append: (
<EuiBadge color="accent">
{i18n.translate('xpack.apm.universalProfiling.newLabel', {

View file

@ -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,