Skip to content

Commit

Permalink
[8.x] [Inventory] Promote new inventory plugin in APM (#193997) (#194443
Browse files Browse the repository at this point in the history
)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Inventory] Promote new inventory plugin in APM
(#193997)](#193997)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Irene
Blanco","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-09-30T14:38:45Z","message":"[Inventory]
Promote new inventory plugin in APM (#193997)\n\n##
Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/192856.\r\n\r\nThis PR removes
the ability to enable the new APM experience and\r\nreplaces it with a
link promoting the new Inventory feature.\r\n\r\n![Screen Recording
2024-09-25 at 15
02\r\n29](https://github.com/user-attachments/assets/5dc6b8af-f207-43e5-8125-fffb4b823e4d)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"9f9d911dbacc45729fd6e93bad0e08a761eb8823","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:prev-minor","ci:project-deploy-observability","Team:obs-ux-infra_services","v8.16.0"],"title":"[Inventory]
Promote new inventory plugin in
APM","number":193997,"url":"https://github.com/elastic/kibana/pull/193997","mergeCommit":{"message":"[Inventory]
Promote new inventory plugin in APM (#193997)\n\n##
Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/192856.\r\n\r\nThis PR removes
the ability to enable the new APM experience and\r\nreplaces it with a
link promoting the new Inventory feature.\r\n\r\n![Screen Recording
2024-09-25 at 15
02\r\n29](https://github.com/user-attachments/assets/5dc6b8af-f207-43e5-8125-fffb4b823e4d)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"9f9d911dbacc45729fd6e93bad0e08a761eb8823"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/193997","number":193997,"mergeCommit":{"message":"[Inventory]
Promote new inventory plugin in APM (#193997)\n\n##
Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/192856.\r\n\r\nThis PR removes
the ability to enable the new APM experience and\r\nreplaces it with a
link promoting the new Inventory feature.\r\n\r\n![Screen Recording
2024-09-25 at 15
02\r\n29](https://github.com/user-attachments/assets/5dc6b8af-f207-43e5-8125-fffb4b823e4d)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"9f9d911dbacc45729fd6e93bad0e08a761eb8823"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Irene Blanco <[email protected]>
  • Loading branch information
kibanamachine and iblancof authored Sep 30, 2024
1 parent 629b0a9 commit ad413cc
Show file tree
Hide file tree
Showing 14 changed files with 151 additions and 482 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,8 @@
* 2.0.
*/
import React from 'react';
import { i18n } from '@kbn/i18n';
import { EuiEmptyPrompt, EuiLoadingLogo } from '@elastic/eui';
import { isEmpty } from 'lodash';
import { ApmServiceInventory } from './apm_signal_inventory';
import { MultiSignalInventory } from './multi_signal_inventory';
import { useApmParams } from '../../../hooks/use_apm_params';
import { useEntityManagerEnablementContext } from '../../../context/entity_manager_context/use_entity_manager_enablement_context';

export function ServiceInventory() {
const { isEnablementPending, isEntityCentricExperienceViewEnabled } =
useEntityManagerEnablementContext();

const {
query: { serviceGroup },
} = useApmParams('/services');

if (isEnablementPending) {
return (
<EuiEmptyPrompt
icon={<EuiLoadingLogo logo="logoObservability" size="xl" />}
title={
<h2>
{i18n.translate('xpack.apm.loadingService', {
defaultMessage: 'Loading services',
})}
</h2>
}
/>
);
}

return isEntityCentricExperienceViewEnabled && isEmpty(serviceGroup) ? (
<MultiSignalInventory />
) : (
<ApmServiceInventory />
);
return <ApmServiceInventory />;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { EuiFlexGroup, EuiFlexItem, EuiLink, EuiToolTip, EuiButtonIcon } from '@elastic/eui';
import { TechnicalPreviewBadge } from '@kbn/observability-shared-plugin/public';
import React from 'react';
import { FormattedMessage } from '@kbn/i18n-react';
import { useKibana } from '@kbn/kibana-react-plugin/public';
import { ApmPluginStartDeps } from '../../../../plugin';

interface EntitiesInventoryCalloutProps {
onDissmiss: () => void;
}

export function EntitiesInventoryCallout({ onDissmiss }: EntitiesInventoryCalloutProps) {
const { services } = useKibana<ApmPluginStartDeps>();
const { observabilityShared } = services;

const entitiesInventoryLocator = observabilityShared.locators.entitiesInventory;

return (
<EuiFlexGroup direction="row" alignItems="center" gutterSize="xs">
<EuiFlexItem grow={false}>
<TechnicalPreviewBadge icon="beaker" style={{ verticalAlign: 'middle' }} />
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiLink
data-test-subj="apmEntitiesInventoryCalloutLink"
href={entitiesInventoryLocator.useUrl({})}
>
<FormattedMessage
id="xpack.apm.entitiesInventoryCallout.linklabel"
defaultMessage="Try our new Inventory!"
/>
</EuiLink>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiToolTip
content={
<FormattedMessage
id="xpack.apm.entitiesInventoryCallout.linkTooltip"
defaultMessage="Hide this"
/>
}
>
<EuiButtonIcon
data-test-subj="apmEntitiesInventoryCalloutDismiss"
iconType="cross"
onClick={onDissmiss}
/>
</EuiToolTip>
</EuiFlexItem>
</EuiFlexGroup>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,22 @@ import { entityCentricExperience } from '@kbn/observability-plugin/common';
import { ObservabilityPageTemplateProps } from '@kbn/observability-shared-plugin/public';
import type { KibanaPageTemplateProps } from '@kbn/shared-ux-page-kibana-template';
import React, { useContext } from 'react';
import { i18n } from '@kbn/i18n';
import { useLocation } from 'react-router-dom';
import { FeatureFeedbackButton } from '@kbn/observability-shared-plugin/public';
import { useEntityManagerEnablementContext } from '../../../context/entity_manager_context/use_entity_manager_enablement_context';
import { useDefaultAiAssistantStarterPromptsForAPM } from '../../../hooks/use_default_ai_assistant_starter_prompts_for_apm';
import { KibanaEnvironmentContext } from '../../../context/kibana_environment_context/kibana_environment_context';
import { getPathForFeedback } from '../../../utils/get_path_for_feedback';
import { EnvironmentsContextProvider } from '../../../context/environments_context/environments_context';
import { FETCH_STATUS, useFetcher } from '../../../hooks/use_fetcher';
import { ApmPluginStartDeps } from '../../../plugin';
import { ServiceGroupSaveButton } from '../../app/service_groups';
import { ServiceGroupsButtonGroup } from '../../app/service_groups/service_groups_button_group';
import { ApmEnvironmentFilter } from '../../shared/environment_filter';
import { getNoDataConfig } from './no_data_config';
import { useApmPluginContext } from '../../../context/apm_plugin/use_apm_plugin_context';
import { EntityEnablement } from '../../shared/entity_enablement';
import { CustomNoDataTemplate } from './custom_no_data_template';
import { ServiceInventoryView } from '../../../context/entity_manager_context/entity_manager_context';
import { useLocalStorage } from '../../../../hooks/use_local_storage';
import { useEntityManagerEnablementContext } from '../../../../context/entity_manager_context/use_entity_manager_enablement_context';
import { useDefaultAiAssistantStarterPromptsForAPM } from '../../../../hooks/use_default_ai_assistant_starter_prompts_for_apm';
import { KibanaEnvironmentContext } from '../../../../context/kibana_environment_context/kibana_environment_context';
import { getPathForFeedback } from '../../../../utils/get_path_for_feedback';
import { EnvironmentsContextProvider } from '../../../../context/environments_context/environments_context';
import { FETCH_STATUS, useFetcher } from '../../../../hooks/use_fetcher';
import { ApmPluginStartDeps } from '../../../../plugin';
import { ServiceGroupSaveButton } from '../../../app/service_groups';
import { ServiceGroupsButtonGroup } from '../../../app/service_groups/service_groups_button_group';
import { ApmEnvironmentFilter } from '../../../shared/environment_filter';
import { getNoDataConfig } from '../no_data_config';
import { useApmPluginContext } from '../../../../context/apm_plugin/use_apm_plugin_context';
import { EntitiesInventoryCallout } from './entities_inventory_callout';

// Paths that must skip the no data screen
const bypassNoDataScreenPaths = ['/settings', '/diagnostics'];
Expand Down Expand Up @@ -78,8 +76,8 @@ export function ApmMainTemplate({
entityCentricExperience,
true
);
const { isEntityCentricExperienceViewEnabled, serviceInventoryViewLocalStorageSetting } =
useEntityManagerEnablementContext();

const { isEntityCentricExperienceViewEnabled } = useEntityManagerEnablementContext();

const ObservabilityPageTemplate = observabilityShared.navigation.PageTemplate;

Expand Down Expand Up @@ -117,11 +115,6 @@ export function ApmMainTemplate({

const hasApmData = !!data?.hasData;
const hasApmIntegrations = !!fleetApmPoliciesData?.hasApmPolicies;
const showCustomEmptyState =
!hasApmData &&
!isLoading &&
isEntityCentricExperienceSettingEnabled &&
serviceInventoryViewLocalStorageSetting === ServiceInventoryView.classic;

const noDataConfig = getNoDataConfig({
basePath,
Expand All @@ -142,6 +135,7 @@ export function ApmMainTemplate({
const rightSideItems = [...(showServiceGroupSaveButton ? [<ServiceGroupSaveButton />] : [])];

const sanitizedPath = getPathForFeedback(window.location.pathname);

const pageHeaderTitle = (
<EuiFlexGroup justifyContent="spaceBetween" wrap={true}>
{pageHeader?.pageTitle ?? pageTitle}
Expand All @@ -168,47 +162,44 @@ export function ApmMainTemplate({
</EuiFlexGroup>
);

const pageTemplate = showCustomEmptyState ? (
<CustomNoDataTemplate isPageDataLoaded={isLoading === false} noDataConfig={noDataConfig} />
) : (
<ObservabilityPageTemplate
noDataConfig={
shouldBypassNoDataScreen ||
serviceInventoryViewLocalStorageSetting === ServiceInventoryView.entity
? undefined
: noDataConfig
}
isPageDataLoaded={isLoading === false}
pageHeader={{
rightSideItems,
...pageHeader,
pageTitle: pageHeaderTitle,
children: (
<EuiFlexGroup direction="column">
{isEntityCentricExperienceSettingEnabled &&
showEnablementCallout &&
selectedNavButton === 'allServices' ? (
<EntityEnablement
label={i18n.translate('xpack.apm.eemEnablement.tryItButton.', {
defaultMessage: 'Try our new experience!',
})}
tooltip={i18n.translate('xpack.apm.entityEnablement.content', {
defaultMessage:
'Our new experience combines both APM-instrumented services with services detected from logs in a single service inventory.',
})}
/>
) : null}
{showServiceGroupsNav && selectedNavButton && (
<ServiceGroupsButtonGroup selectedNavButton={selectedNavButton} />
)}
</EuiFlexGroup>
),
}}
{...pageTemplateProps}
>
{children}
</ObservabilityPageTemplate>
const [dismissedEntitiesInventoryCallout, setdismissedEntitiesInventoryCallout] = useLocalStorage(
`apm.dismissedEntitiesInventoryCallout`,
false
);

return <EnvironmentsContextProvider>{pageTemplate}</EnvironmentsContextProvider>;
const showEntitiesInventoryCallout =
!dismissedEntitiesInventoryCallout &&
isEntityCentricExperienceSettingEnabled &&
selectedNavButton !== undefined;

return (
<EnvironmentsContextProvider>
<ObservabilityPageTemplate
noDataConfig={shouldBypassNoDataScreen ? undefined : noDataConfig}
isPageDataLoaded={isLoading === false}
pageHeader={{
rightSideItems,
...pageHeader,
pageTitle: pageHeaderTitle,
children: (
<EuiFlexGroup direction="column">
{showEntitiesInventoryCallout ? (
<EntitiesInventoryCallout
onDissmiss={() => {
setdismissedEntitiesInventoryCallout(true);
}}
/>
) : null}
{showServiceGroupsNav && selectedNavButton && (
<ServiceGroupsButtonGroup selectedNavButton={selectedNavButton} />
)}
</EuiFlexGroup>
),
}}
{...pageTemplateProps}
>
{children}
</ObservabilityPageTemplate>
</EnvironmentsContextProvider>
);
}
Loading

0 comments on commit ad413cc

Please sign in to comment.