Skip to content

Commit c2a3e2a

Browse files
crespocarlosMiriamApariciokibanamachineelasticmachine
authored
[8.19] Add feature flag for service map api v2 (#214227) (#219991)
# Backport This will backport the following commits from `main` to `8.19`: - [Add feature flag for service map api v2 (#214227)](#214227) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Miriam","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-03-14T14:55:53Z","message":"Add feature flag for service map api v2 (#214227)\n\nCloses https://github.com/elastic/kibana/issues/213125\n\n### Summary\n\nAdded feature flag to enable the new service map api\nNot specific telemetry for events was added, the advance settings have\ntelemetry already out of the box\n\n\nhttps://github.com/user-attachments/assets/684bd369-c46d-4ac0-ab07-33b5395a7f71\n\n<img width=\"778\" alt=\"Screenshot 2025-03-13 at 14 20 37\"\nsrc=\"https://github.com/user-attachments/assets/6445e85f-1108-43d1-aeee-a340cdfe99b8\"\n/>\n\n### How to test\n\n- Inspect the response. v2 has a `spans` object, and the current version\nhas an `elements` object\n\n---------\n\nCo-authored-by: kibanamachine <[email protected]>","sha":"3ff1340c01e17fcb8187f0e6e81b52a6c6053346","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:skip","Team:obs-ux-infra_services","Team:obs-ux-management","v9.1.0","v8.19.0"],"title":"Add feature flag for service map api v2","number":214227,"url":"https://github.com/elastic/kibana/pull/214227","mergeCommit":{"message":"Add feature flag for service map api v2 (#214227)\n\nCloses https://github.com/elastic/kibana/issues/213125\n\n### Summary\n\nAdded feature flag to enable the new service map api\nNot specific telemetry for events was added, the advance settings have\ntelemetry already out of the box\n\n\nhttps://github.com/user-attachments/assets/684bd369-c46d-4ac0-ab07-33b5395a7f71\n\n<img width=\"778\" alt=\"Screenshot 2025-03-13 at 14 20 37\"\nsrc=\"https://github.com/user-attachments/assets/6445e85f-1108-43d1-aeee-a340cdfe99b8\"\n/>\n\n### How to test\n\n- Inspect the response. v2 has a `spans` object, and the current version\nhas an `elements` object\n\n---------\n\nCo-authored-by: kibanamachine <[email protected]>","sha":"3ff1340c01e17fcb8187f0e6e81b52a6c6053346"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/214227","number":214227,"mergeCommit":{"message":"Add feature flag for service map api v2 (#214227)\n\nCloses https://github.com/elastic/kibana/issues/213125\n\n### Summary\n\nAdded feature flag to enable the new service map api\nNot specific telemetry for events was added, the advance settings have\ntelemetry already out of the box\n\n\nhttps://github.com/user-attachments/assets/684bd369-c46d-4ac0-ab07-33b5395a7f71\n\n<img width=\"778\" alt=\"Screenshot 2025-03-13 at 14 20 37\"\nsrc=\"https://github.com/user-attachments/assets/6445e85f-1108-43d1-aeee-a340cdfe99b8\"\n/>\n\n### How to test\n\n- Inspect the response. v2 has a `spans` object, and the current version\nhas an `elements` object\n\n---------\n\nCo-authored-by: kibanamachine <[email protected]>","sha":"3ff1340c01e17fcb8187f0e6e81b52a6c6053346"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> --------- Co-authored-by: Miriam <[email protected]> Co-authored-by: kibanamachine <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
1 parent 1b7339d commit c2a3e2a

File tree

15 files changed

+113
-15
lines changed

15 files changed

+113
-15
lines changed

src/platform/plugins/private/kibana_usage_collection/server/collectors/management/schema.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,10 @@ export const stackManagementSchema: MakeSchemaFrom<UsageStats> = {
496496
type: 'integer',
497497
_meta: { description: 'Non-default value of setting.' },
498498
},
499+
'observability:apmEnableServiceMapApiV2': {
500+
type: 'boolean',
501+
_meta: { description: 'Non-default value of setting.' },
502+
},
499503
'observability:aiAssistantSimulatedFunctionCalling': {
500504
type: 'boolean',
501505
_meta: { description: 'Non-default value of setting.' },

src/platform/plugins/private/kibana_usage_collection/server/collectors/management/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export interface UsageStats {
5454
'observability:apmEnableTableSearchBar': boolean;
5555
'observability:apmEnableServiceInventoryTableSearchBar': boolean;
5656
'observability:logsExplorer:allowedDataViews': string[];
57+
'observability:apmEnableServiceMapApiV2': boolean;
5758
'observability:logSources': string[];
5859
'observability:enableLogsStream': boolean;
5960
'observability:newLogsOverview': boolean;

src/platform/plugins/shared/telemetry/schema/oss_platform.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11298,6 +11298,12 @@
1129811298
"description": "Non-default value of setting."
1129911299
}
1130011300
},
11301+
"observability:apmEnableServiceMapApiV2": {
11302+
"type": "boolean",
11303+
"_meta": {
11304+
"description": "Non-default value of setting."
11305+
}
11306+
},
1130111307
"observability:aiAssistantSimulatedFunctionCalling": {
1130211308
"type": "boolean",
1130311309
"_meta": {

src/platform/test/plugin_functional/test_suites/core_plugins/rendering.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ export default function ({ getService }: PluginFunctionalProviderContext) {
208208
'xpack.apm.serviceMapEnabled (boolean?)',
209209
'xpack.apm.ui.enabled (boolean?)',
210210
'xpack.apm.ui.maxTraceItems (number?)',
211-
'xpack.apm.ui.serviceMapApiV2Enabled (boolean?)',
212211
'xpack.apm.managedServiceUrl (string?|never)',
213212
'xpack.apm.serverlessOnboarding (boolean?|never)',
214213
'xpack.apm.latestAgentVersionsUrl (string?)',

x-pack/solutions/observability/plugins/apm/public/components/app/service_map/index.tsx

Lines changed: 68 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@
66
*/
77

88
import { usePerformanceContext } from '@kbn/ebt-tools';
9-
import { EuiFlexGroup, EuiFlexItem, EuiLoadingSpinner, EuiPanel } from '@elastic/eui';
9+
import { i18n } from '@kbn/i18n';
10+
import { EuiFlexGroup, EuiFlexItem, EuiLoadingSpinner, EuiPanel, EuiSpacer } from '@elastic/eui';
1011
import type { ReactNode } from 'react';
11-
import React from 'react';
12+
import React, { useEffect, useRef, useState } from 'react';
13+
import { apmEnableServiceMapApiV2 } from '@kbn/observability-plugin/common';
14+
import { useEditableSettings } from '@kbn/observability-shared-plugin/public';
15+
import { Subscription } from 'rxjs';
1216
import { useApmPluginContext } from '../../../context/apm_plugin/use_apm_plugin_context';
1317
import { isActivePlatinumLicense } from '../../../../common/license_check';
1418
import { invalidLicenseMessage, SERVICE_MAP_TIMEOUT_ERROR } from '../../../../common/service_map';
@@ -34,6 +38,7 @@ import { useApmServiceContext } from '../../../context/apm_service/use_apm_servi
3438
import { isLogsOnlySignal } from '../../../utils/get_signal_type';
3539
import { ServiceTabEmptyState } from '../service_tab_empty_state';
3640
import { useServiceMap } from './use_service_map';
41+
import { TryItButton } from '../../shared/try_it_button';
3742

3843
function PromptContainer({ children }: { children: ReactNode }) {
3944
return (
@@ -109,15 +114,42 @@ export function ServiceMap({
109114
const license = useLicenseContext();
110115
const serviceName = useServiceName();
111116

112-
const { config } = useApmPluginContext();
117+
const { config, core } = useApmPluginContext();
113118
const { onPageReady } = usePerformanceContext();
119+
120+
const subscriptions = useRef<Subscription>(new Subscription());
121+
const [isServiceMapApiV2Enabled, setIsServiceMapApiV2Enabled] = useState<boolean>(
122+
core.settings.client.get(apmEnableServiceMapApiV2)
123+
);
124+
125+
useEffect(() => {
126+
subscriptions.current.add(
127+
core.settings.client.get$<boolean>(apmEnableServiceMapApiV2).subscribe((value) => {
128+
setIsServiceMapApiV2Enabled(value);
129+
})
130+
);
131+
}, [core.settings]);
132+
133+
useEffect(() => {
134+
const currentSubscriptions = subscriptions.current;
135+
return () => {
136+
currentSubscriptions.unsubscribe();
137+
};
138+
}, []);
139+
140+
const { fields, isSaving, saveSingleSetting } = useEditableSettings([apmEnableServiceMapApiV2]);
141+
142+
const settingsField = fields[apmEnableServiceMapApiV2];
143+
const isServiceMapV2Enabled = Boolean(settingsField?.savedValue ?? settingsField?.defaultValue);
144+
114145
const { data, status, error } = useServiceMap({
115146
environment,
116147
kuery,
117148
start,
118149
end,
119150
serviceGroupId,
120151
serviceName,
152+
isServiceMapApiV2Enabled,
121153
});
122154

123155
const { ref, height } = useRefDimensions();
@@ -183,6 +215,39 @@ export function ServiceMap({
183215
return (
184216
<>
185217
<SearchBar showTimeComparison />
218+
<EuiFlexGroup alignItems="center" justifyContent="flexStart" gutterSize="s">
219+
<TryItButton
220+
isFeatureEnabled={isServiceMapV2Enabled}
221+
linkLabel={
222+
isServiceMapV2Enabled
223+
? i18n.translate('xpack.apm.serviceMap.disableServiceMapApiV2', {
224+
defaultMessage: 'Disable the new service map API',
225+
})
226+
: i18n.translate('xpack.apm.serviceMap.enableServiceMapApiV2', {
227+
defaultMessage: 'Enable the new service map API',
228+
})
229+
}
230+
onClick={() => {
231+
saveSingleSetting(apmEnableServiceMapApiV2, !isServiceMapV2Enabled);
232+
}}
233+
isLoading={isSaving}
234+
popoverContent={
235+
<EuiFlexGroup direction="column" gutterSize="s">
236+
<EuiFlexItem grow={false}>
237+
{i18n.translate('xpack.apm.serviceMap.serviceMapApiV2PopoverContent', {
238+
defaultMessage: 'The new service map API is faster, try it out!',
239+
})}
240+
</EuiFlexItem>
241+
</EuiFlexGroup>
242+
}
243+
hideThisContent={i18n.translate('xpack.apm.serviceMap.hideThisContent', {
244+
defaultMessage:
245+
'Hide this. The setting can be enabled or disabled in Advanced Settings.',
246+
})}
247+
calloutId="showServiceMapV2Callout"
248+
/>
249+
</EuiFlexGroup>
250+
<EuiSpacer size="s" />
186251
<EuiPanel hasBorder={true} paddingSize="none">
187252
<div data-test-subj="serviceMap" style={{ height: heightWithPadding }} ref={ref}>
188253
<Cytoscape

x-pack/solutions/observability/plugins/apm/public/components/app/service_map/use_service_map.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,15 @@ export const useServiceMap = ({
3838
serviceName,
3939
serviceGroupId,
4040
kuery,
41+
isServiceMapApiV2Enabled,
4142
}: {
4243
environment: Environment;
4344
kuery: string;
4445
start: string;
4546
end: string;
4647
serviceGroupId?: string;
4748
serviceName?: string;
49+
isServiceMapApiV2Enabled: boolean;
4850
}) => {
4951
const license = useLicenseContext();
5052
const { config } = useApmPluginContext();
@@ -74,7 +76,7 @@ export const useServiceMap = ({
7476
serviceName,
7577
serviceGroup: serviceGroupId,
7678
kuery,
77-
useV2: config.ui.serviceMapApiV2Enabled,
79+
useV2: isServiceMapApiV2Enabled,
7880
},
7981
},
8082
});
@@ -88,7 +90,7 @@ export const useServiceMap = ({
8890
serviceGroupId,
8991
kuery,
9092
config.serviceMapEnabled,
91-
config.ui.serviceMapApiV2Enabled,
93+
isServiceMapApiV2Enabled,
9294
],
9395
{ preservePreviousData: false }
9496
);

x-pack/solutions/observability/plugins/apm/public/components/app/settings/general_settings/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
apmEnableTableSearchBar,
2424
apmEnableTransactionProfiling,
2525
apmEnableServiceInventoryTableSearchBar,
26+
apmEnableServiceMapApiV2,
2627
} from '@kbn/observability-plugin/common';
2728
import { isEmpty } from 'lodash';
2829
import React from 'react';
@@ -56,6 +57,7 @@ function getApmSettingsKeys(isProfilingIntegrationEnabled: boolean) {
5657
enableAgentExplorerView,
5758
apmEnableTableSearchBar,
5859
apmEnableServiceInventoryTableSearchBar,
60+
apmEnableServiceMapApiV2,
5961
];
6062

6163
if (isProfilingIntegrationEnabled) {

x-pack/solutions/observability/plugins/apm/public/components/shared/try_it_button/index.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ interface Props {
2929
onClick: () => void;
3030
popoverContent?: React.ReactElement;
3131
isLoading: boolean;
32+
calloutId: string;
33+
hideThisContent: string;
3234
}
3335

3436
export function TryItButton({
@@ -38,16 +40,15 @@ export function TryItButton({
3840
popoverContent,
3941
promoLabel,
4042
isLoading,
43+
calloutId,
44+
hideThisContent,
4145
}: Props) {
42-
const [showFastFilterTryCallout, setShowFastFilterTryCallout] = useLocalStorage(
43-
'apm.showFastFilterTryCallout',
44-
true
45-
);
46+
const [showTryCallout, setShowFastFilterTryCallout] = useLocalStorage(`apm.${calloutId}`, true);
4647
const { core } = useApmPluginContext();
4748
const canEditAdvancedSettings = core.application.capabilities.advancedSettings?.save;
4849
const [isPopoverOpen, togglePopover] = useToggle(false);
4950

50-
if (!showFastFilterTryCallout) {
51+
if (!showTryCallout) {
5152
return null;
5253
}
5354

@@ -169,7 +170,7 @@ export function TryItButton({
169170
function HideThisButton() {
170171
return (
171172
<EuiFlexItem grow={false}>
172-
<EuiToolTip content="Hide this">
173+
<EuiToolTip content={hideThisContent}>
173174
<EuiButtonIcon
174175
data-test-subj="apmHideThisButtonButton"
175176
iconType="cross"

x-pack/solutions/observability/plugins/apm/public/context/apm_plugin/mock_apm_plugin_context.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ const mockCore = merge({}, coreStart, {
9797
const mockConfig: ConfigSchema = {
9898
serviceMapEnabled: true,
9999
ui: {
100-
serviceMapApiV2Enabled: false,
101100
enabled: false,
102101
},
103102
latestAgentVersionsUrl: '',

x-pack/solutions/observability/plugins/apm/public/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { ApmPlugin } from './plugin';
1212
export interface ConfigSchema {
1313
serviceMapEnabled: boolean;
1414
ui: {
15-
serviceMapApiV2Enabled: boolean;
1615
enabled: boolean;
1716
};
1817
latestAgentVersionsUrl: string;

0 commit comments

Comments
 (0)