From dd6ec852f149a1c18194e55facd3cf62acde2f9f Mon Sep 17 00:00:00 2001 From: Sumukh Swamy Date: Thu, 25 Jul 2024 16:11:14 -0700 Subject: [PATCH 1/9] updated release notes (#1997) Signed-off-by: sumukhswamy From 494e324e8b9ec5e19169b13012434873989bc8d2 Mon Sep 17 00:00:00 2001 From: Sumukh Swamy Date: Thu, 25 Jul 2024 16:11:14 -0700 Subject: [PATCH 2/9] updated release notes (#1997) Signed-off-by: sumukhswamy From 1fe9efedd197315630c6b964b72c8f74db72b3ee Mon Sep 17 00:00:00 2001 From: Eric Date: Fri, 11 Oct 2024 00:54:08 +0000 Subject: [PATCH 3/9] add template creation to assests creation flow Signed-off-by: Eric --- .../getting_started_collectData.tsx | 12 +++- .../getting_started/components/utils.tsx | 60 ++++++++++++++++++- .../getting_started/getting_started_router.ts | 17 +++++- server/routes/getting_started/helper.ts | 45 ++++++++++++++ 4 files changed, 129 insertions(+), 5 deletions(-) diff --git a/public/components/getting_started/components/getting_started_collectData.tsx b/public/components/getting_started/components/getting_started_collectData.tsx index 0028486cc..239d0f4cf 100644 --- a/public/components/getting_started/components/getting_started_collectData.tsx +++ b/public/components/getting_started/components/getting_started_collectData.tsx @@ -52,7 +52,7 @@ interface CollectAndShipDataProps { selectedDataSourceLabel: string; } -interface CollectorOption { +export interface CollectorOption { label: string; value: string; } @@ -347,7 +347,15 @@ export const CollectAndShipData: React.FC = ({ { - await UploadAssets(specificMethod, selectedDataSourceId, selectedDataSourceLabel); + await UploadAssets( + specificMethod, + selectedDataSourceId, + selectedDataSourceLabel, + technologyJsonMap[specificMethod]?.['getting-started']?.schema || + technologyJsonMap[specificMethod]?.schema || + [], + collectorOptions + ); }} fill > diff --git a/public/components/getting_started/components/utils.tsx b/public/components/getting_started/components/utils.tsx index 3c50f3072..21566ddc8 100644 --- a/public/components/getting_started/components/utils.tsx +++ b/public/components/getting_started/components/utils.tsx @@ -3,8 +3,27 @@ * SPDX-License-Identifier: Apache-2.0 */ +import { MappingTypeMapping } from '@opensearch-project/opensearch/api/types'; +import { EuiSelectableOption } from '@elastic/eui'; import { coreRefs } from '../../../framework/core_refs'; import { useToast } from '../../../../public/components/common/toast'; +import { CollectorOption } from './getting_started_collectData'; + +export interface ICollectorIndexTemplate { + name: string; + templatePath: string; + template: MappingTypeMapping; +} + +export interface ICollectorSchema { + alias: string; + content: string; + description: string; + 'index-pattern-name': string; + type: string; + 'index-template': string; + info: string[]; +} const fetchAssets = async (tutorialId: string, assetFilter?: 'dashboards' | 'indexPatterns') => { const assetFilterParam = assetFilter ? `${assetFilter}/` : ''; @@ -20,16 +39,55 @@ const fetchAssets = async (tutorialId: string, assetFilter?: 'dashboards' | 'ind return responeData; }; -export const UploadAssets = async (tutorialId: string, mdsId: string, mdsLabel: string) => { +export const UploadAssets = async ( + tutorialId: string, + mdsId: string, + mdsLabel: string, + schema: ICollectorSchema[], + collectorOptions: Array> +) => { const { setToast } = useToast(); const http = coreRefs.http; + let selectedIntegration: string | undefined; + const checkedCollector = collectorOptions.find((collector) => { + return !!collector.checked; + }); + + if (checkedCollector !== undefined) { + if (checkedCollector.value === 'otel') { + selectedIntegration = 'otel-services'; + } else if (checkedCollector.value === 'nginx') { + selectedIntegration = checkedCollector.value; + } + } + try { + // Auto-generate index templates based on the selected integration + let templates: ICollectorIndexTemplate[] = []; + if (selectedIntegration !== undefined) { + const indexTemplateMappings = await http!.get( + `/api/integrations/repository/${selectedIntegration}/schema` + ); + templates = schema.reduce((acc: ICollectorIndexTemplate[], sh) => { + const templateMapping = indexTemplateMappings?.data?.mappings?.[sh.type]; + if (!!templateMapping) { + acc.push({ + name: sh.content.match(/[^/]+$/)?.[0] || '', + templatePath: sh.content.match(/PUT\s+(.+)/)?.[1] || '', + template: templateMapping, + }); + } + return acc; + }, []); + } + const response = await http!.post(`/api/observability/gettingStarted/createAssets`, { body: JSON.stringify({ mdsId, mdsLabel, tutorialId, + indexTemplates: templates, }), }); diff --git a/server/routes/getting_started/getting_started_router.ts b/server/routes/getting_started/getting_started_router.ts index 4bdd7dfb8..596464ae5 100644 --- a/server/routes/getting_started/getting_started_router.ts +++ b/server/routes/getting_started/getting_started_router.ts @@ -12,7 +12,7 @@ import { SavedObject, } from '../../../../../src/core/server'; import { createSavedObjectsStreamFromNdJson } from '../../../../../src/core/server/saved_objects/routes/utils'; -import { loadAssetsFromFile } from './helper'; +import { loadAssetsFromFile, createAllTemplatesSettled } from './helper'; import { getWorkspaceState } from '../../../../../src/core/server/utils'; import { TutorialId } from '../../../common/constants/getting_started_routes'; @@ -99,6 +99,14 @@ export function registerGettingStartedRoutes(router: IRouter) { mdsId: schema.string(), mdsLabel: schema.string(), tutorialId: schema.string(), + indexTemplates: schema.arrayOf( + schema.object({ + name: schema.string(), + templatePath: schema.string(), + template: schema.recordOf(schema.string(), schema.any()), + }), + { defaultValue: [] } + ), }), }, }, @@ -108,10 +116,15 @@ export function registerGettingStartedRoutes(router: IRouter) { response ): Promise> => { try { - const { mdsId, mdsLabel, tutorialId } = request.body; + const { mdsId, mdsLabel, tutorialId, indexTemplates } = request.body; const { requestWorkspaceId } = getWorkspaceState(request); const fileData = await loadAssetsFromFile(tutorialId as TutorialId); + // create related index templates + if (indexTemplates.length > 0) { + await createAllTemplatesSettled(context, indexTemplates, mdsId); + } + const objects = await createSavedObjectsStreamFromNdJson(Readable.from(fileData)); const loadedObjects = await objects.toArray(); diff --git a/server/routes/getting_started/helper.ts b/server/routes/getting_started/helper.ts index c9375301f..2d4501e11 100644 --- a/server/routes/getting_started/helper.ts +++ b/server/routes/getting_started/helper.ts @@ -11,6 +11,8 @@ import { SIGNAL_MAP, TutorialId, } from '../../../common/constants/getting_started_routes'; +import { MappingTypeMapping } from '@opensearch-project/opensearch/api/types'; +import { RequestHandlerContext } from '../../../../../src/core/server'; export const assetMapper = (tutorialId: TutorialId): string => { const component = COMPONENT_MAP[tutorialId] || 'default-component'; @@ -30,3 +32,46 @@ export const loadAssetsFromFile = async (tutorialId: TutorialId) => { throw new Error(`Error loading asset: ${tutorialId}`); } }; + +export const createAllTemplatesSettled = async ( + context: RequestHandlerContext, + indexTemplates: Array<{ name: string; template: MappingTypeMapping; templatePath: string }>, + dataSourceMDSId: string +) => { + const results = await Promise.allSettled( + indexTemplates.map(({ name, template, templatePath }) => + createIndexTemplate(context, name, template, dataSourceMDSId, templatePath) + ) + ); + + return results.map((result, index) => { + const templateName = indexTemplates[index].name; + if (result.status === 'fulfilled') { + return { name: templateName, success: true }; + } + return { name: templateName, success: false, reason: result.reason }; + }); +}; + +export const createIndexTemplate = async ( + context: RequestHandlerContext, + name: string, + template: MappingTypeMapping, + dataSourceMDSId: string, + templatePath: string +) => { + try { + const osClient = dataSourceMDSId + ? await context.dataSource.opensearch.getClient(dataSourceMDSId) + : context.core.opensearch.client.asCurrentUser; + + return await osClient.transport.request({ + method: 'PUT', + path: templatePath, + body: template, + }); + } catch (error) { + console.error(`Failed to create index template ${name}:`, error); + throw error; + } +}; From dc1bc56a994f3099e3a28beb4d402560509af15f Mon Sep 17 00:00:00 2001 From: Eric Date: Mon, 14 Oct 2024 06:44:51 +0000 Subject: [PATCH 4/9] adopt recent UI changes for the same flow Signed-off-by: Eric --- .../getting_started_collectData.tsx | 12 +++++++--- .../getting_started/components/utils.tsx | 24 ++++++++----------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/public/components/getting_started/components/getting_started_collectData.tsx b/public/components/getting_started/components/getting_started_collectData.tsx index 239d0f4cf..9c8199b54 100644 --- a/public/components/getting_started/components/getting_started_collectData.tsx +++ b/public/components/getting_started/components/getting_started_collectData.tsx @@ -21,6 +21,7 @@ import { EuiButton, EuiIcon, EuiCard, + EuiSelectableOption, } from '@elastic/eui'; import React, { useEffect, useState } from 'react'; @@ -44,6 +45,7 @@ import { getWorkspaceIdFromUrl } from '../../../../../../src/core/public/utils'; const cardOne = 'Logs'; const cardTwo = 'Metrics'; const cardThree = 'Traces'; +const OTEL_LOGS_OPTION = { label: 'Open Telemetry', value: 'otelLogs' }; interface CollectAndShipDataProps { isOpen: boolean; @@ -69,6 +71,9 @@ export const CollectAndShipData: React.FC = ({ const [workflows, setWorkflows] = useState([]); const [collectorOptions, setCollectorOptions] = useState([]); const [patternsContent, setPatternsContent] = useState([]); + const [selectedIntegration, setSelectedIntegration] = useState< + Array> + >([OTEL_LOGS_OPTION]); const technologyJsonMap: Record = { otelLogs: otelJsonLogs, @@ -129,6 +134,7 @@ export const CollectAndShipData: React.FC = ({ return; } + setSelectedIntegration(newOption); setSpecificMethod(selectedOptionValue); setSelectedWorkflow(''); setGettingStarted(null); @@ -138,7 +144,7 @@ export const CollectAndShipData: React.FC = ({ // Auto-select first collector if nothing is selected and a collection method is set useEffect(() => { if (collectorOptions.length > 0 && !specificMethod && collectionMethod) { - handleSpecificMethodChange([{ value: collectorOptions[0].value }]); + handleSpecificMethodChange([{ ...OTEL_LOGS_OPTION }]); } }, [collectorOptions, specificMethod, collectionMethod]); @@ -151,7 +157,7 @@ export const CollectAndShipData: React.FC = ({ if (value === cardOne) { setCollectorOptions([ - { label: 'Open Telemetry', value: 'otelLogs' }, + { ...OTEL_LOGS_OPTION }, { label: 'Nginx', value: 'nginx' }, { label: 'Java', value: 'java' }, { label: 'Python', value: 'python' }, @@ -354,7 +360,7 @@ export const CollectAndShipData: React.FC = ({ technologyJsonMap[specificMethod]?.['getting-started']?.schema || technologyJsonMap[specificMethod]?.schema || [], - collectorOptions + selectedIntegration ); }} fill diff --git a/public/components/getting_started/components/utils.tsx b/public/components/getting_started/components/utils.tsx index 21566ddc8..420ce5c43 100644 --- a/public/components/getting_started/components/utils.tsx +++ b/public/components/getting_started/components/utils.tsx @@ -44,33 +44,29 @@ export const UploadAssets = async ( mdsId: string, mdsLabel: string, schema: ICollectorSchema[], - collectorOptions: Array> + selectedIntegration: Array> ) => { const { setToast } = useToast(); const http = coreRefs.http; - let selectedIntegration: string | undefined; - const checkedCollector = collectorOptions.find((collector) => { - return !!collector.checked; - }); - - if (checkedCollector !== undefined) { - if (checkedCollector.value === 'otel') { - selectedIntegration = 'otel-services'; - } else if (checkedCollector.value === 'nginx') { - selectedIntegration = checkedCollector.value; + let curIntegration: string | undefined; + if (selectedIntegration !== undefined) { + if (/^otel[A-Za-z]+$/i.test(selectedIntegration[0].value)) { + curIntegration = 'otel-services'; + } else if (selectedIntegration[0].value === 'nginx') { + curIntegration = selectedIntegration[0].value; } } try { // Auto-generate index templates based on the selected integration let templates: ICollectorIndexTemplate[] = []; - if (selectedIntegration !== undefined) { + if (curIntegration !== undefined) { const indexTemplateMappings = await http!.get( - `/api/integrations/repository/${selectedIntegration}/schema` + `/api/integrations/repository/${curIntegration}/schema` ); templates = schema.reduce((acc: ICollectorIndexTemplate[], sh) => { - const templateMapping = indexTemplateMappings?.data?.mappings?.[sh.type]; + const templateMapping = indexTemplateMappings?.data?.mappings?.[sh.type.toLowerCase()]; if (!!templateMapping) { acc.push({ name: sh.content.match(/[^/]+$/)?.[0] || '', From c084206467cb1159c34b6ce1db16aad342c22344 Mon Sep 17 00:00:00 2001 From: Eric Date: Mon, 14 Oct 2024 07:04:16 +0000 Subject: [PATCH 5/9] fix lint issue Signed-off-by: Eric --- server/routes/getting_started/helper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/routes/getting_started/helper.ts b/server/routes/getting_started/helper.ts index 2d4501e11..879e608b1 100644 --- a/server/routes/getting_started/helper.ts +++ b/server/routes/getting_started/helper.ts @@ -5,13 +5,13 @@ import fs from 'fs'; import path from 'path'; +import { MappingTypeMapping } from '@opensearch-project/opensearch/api/types'; import { COMPONENT_MAP, VERSION_MAP, SIGNAL_MAP, TutorialId, } from '../../../common/constants/getting_started_routes'; -import { MappingTypeMapping } from '@opensearch-project/opensearch/api/types'; import { RequestHandlerContext } from '../../../../../src/core/server'; export const assetMapper = (tutorialId: TutorialId): string => { From d898b17e9375220175a6a0afd7f6f537f7447d17 Mon Sep 17 00:00:00 2001 From: Eric Date: Mon, 14 Oct 2024 20:46:15 +0000 Subject: [PATCH 6/9] add types Signed-off-by: Eric --- .../components/getting_started_collectData.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/public/components/getting_started/components/getting_started_collectData.tsx b/public/components/getting_started/components/getting_started_collectData.tsx index 9c8199b54..14d068048 100644 --- a/public/components/getting_started/components/getting_started_collectData.tsx +++ b/public/components/getting_started/components/getting_started_collectData.tsx @@ -127,7 +127,7 @@ export const CollectAndShipData: React.FC = ({ }; }, [specificMethod]); - const handleSpecificMethodChange = (newOption: any) => { + const handleSpecificMethodChange = (newOption: Array>) => { const selectedOptionValue = newOption[0]?.value; if (selectedOptionValue === specificMethod) { @@ -206,7 +206,9 @@ export const CollectAndShipData: React.FC = ({ singleSelection={{ asPlainText: true }} options={optionsWithIcons} selectedOptions={selectedOption ? [selectedOption] : []} - onChange={(newOptions) => handleSpecificMethodChange(newOptions)} + onChange={(newOptions) => + handleSpecificMethodChange(newOptions as Array>) + } renderOption={(option) => (
{option.prepend} From cd9f80660a054fc5081d0e9e08b717fa735713c3 Mon Sep 17 00:00:00 2001 From: Eric Date: Mon, 14 Oct 2024 21:49:15 +0000 Subject: [PATCH 7/9] update snapshots Signed-off-by: Eric --- .../__snapshots__/log_config.test.tsx.snap | 6 ++++++ .../__snapshots__/service_config.test.tsx.snap | 6 ++++++ .../__snapshots__/trace_config.test.tsx.snap | 6 ++++++ .../custom_panel_view.test.tsx.snap | 12 ++++++++++++ .../__snapshots__/panel_grid.test.tsx.snap | 3 +++ .../__snapshots__/metrics_grid.test.tsx.snap | 6 ++++++ .../__snapshots__/dashboard.test.tsx.snap | 18 ++++++++++++++++++ .../__snapshots__/services.test.tsx.snap | 18 ++++++++++++++++++ .../__snapshots__/traces.test.tsx.snap | 18 ++++++++++++++++++ 9 files changed, 93 insertions(+) diff --git a/public/components/application_analytics/__tests__/__snapshots__/log_config.test.tsx.snap b/public/components/application_analytics/__tests__/__snapshots__/log_config.test.tsx.snap index 92fc9e21d..4422eb9c1 100644 --- a/public/components/application_analytics/__tests__/__snapshots__/log_config.test.tsx.snap +++ b/public/components/application_analytics/__tests__/__snapshots__/log_config.test.tsx.snap @@ -20,6 +20,9 @@ exports[`Log Config component renders empty log config 1`] = ` "getHelpExtension$": [MockFunction], "getIsNavDrawerLocked$": [MockFunction], "getIsVisible$": [MockFunction], + "globalSearch": Object { + "getAllSearchCommands": [MockFunction], + }, "logos": Object { "AnimatedMark": Object { "dark": Object { @@ -687,6 +690,9 @@ exports[`Log Config component renders with query 1`] = ` "getHelpExtension$": [MockFunction], "getIsNavDrawerLocked$": [MockFunction], "getIsVisible$": [MockFunction], + "globalSearch": Object { + "getAllSearchCommands": [MockFunction], + }, "logos": Object { "AnimatedMark": Object { "dark": Object { diff --git a/public/components/application_analytics/__tests__/__snapshots__/service_config.test.tsx.snap b/public/components/application_analytics/__tests__/__snapshots__/service_config.test.tsx.snap index 4d3120efd..e3a9c049f 100644 --- a/public/components/application_analytics/__tests__/__snapshots__/service_config.test.tsx.snap +++ b/public/components/application_analytics/__tests__/__snapshots__/service_config.test.tsx.snap @@ -20,6 +20,9 @@ exports[`Service Config component renders empty service config 1`] = ` "getHelpExtension$": [MockFunction], "getIsNavDrawerLocked$": [MockFunction], "getIsVisible$": [MockFunction], + "globalSearch": Object { + "getAllSearchCommands": [MockFunction], + }, "logos": Object { "AnimatedMark": Object { "dark": Object { @@ -1230,6 +1233,9 @@ exports[`Service Config component renders with one service selected 1`] = ` "getHelpExtension$": [MockFunction], "getIsNavDrawerLocked$": [MockFunction], "getIsVisible$": [MockFunction], + "globalSearch": Object { + "getAllSearchCommands": [MockFunction], + }, "logos": Object { "AnimatedMark": Object { "dark": Object { diff --git a/public/components/application_analytics/__tests__/__snapshots__/trace_config.test.tsx.snap b/public/components/application_analytics/__tests__/__snapshots__/trace_config.test.tsx.snap index c55c9eff0..08c6d4552 100644 --- a/public/components/application_analytics/__tests__/__snapshots__/trace_config.test.tsx.snap +++ b/public/components/application_analytics/__tests__/__snapshots__/trace_config.test.tsx.snap @@ -19,6 +19,9 @@ exports[`Trace Config component renders empty trace config 1`] = ` "getHelpExtension$": [MockFunction], "getIsNavDrawerLocked$": [MockFunction], "getIsVisible$": [MockFunction], + "globalSearch": Object { + "getAllSearchCommands": [MockFunction], + }, "logos": Object { "AnimatedMark": Object { "dark": Object { @@ -942,6 +945,9 @@ exports[`Trace Config component renders with one trace selected 1`] = ` "getHelpExtension$": [MockFunction], "getIsNavDrawerLocked$": [MockFunction], "getIsVisible$": [MockFunction], + "globalSearch": Object { + "getAllSearchCommands": [MockFunction], + }, "logos": Object { "AnimatedMark": Object { "dark": Object { diff --git a/public/components/custom_panels/__tests__/__snapshots__/custom_panel_view.test.tsx.snap b/public/components/custom_panels/__tests__/__snapshots__/custom_panel_view.test.tsx.snap index 6cbd8f8eb..26834fc0e 100644 --- a/public/components/custom_panels/__tests__/__snapshots__/custom_panel_view.test.tsx.snap +++ b/public/components/custom_panels/__tests__/__snapshots__/custom_panel_view.test.tsx.snap @@ -1167,6 +1167,9 @@ exports[`Panels View Component renders panel view container with visualizations ], }, "getIsVisible$": [MockFunction], + "globalSearch": Object { + "getAllSearchCommands": [MockFunction], + }, "logos": Object { "AnimatedMark": Object { "dark": Object { @@ -3069,6 +3072,9 @@ exports[`Panels View Component renders panel view container with visualizations ], }, "getIsVisible$": [MockFunction], + "globalSearch": Object { + "getAllSearchCommands": [MockFunction], + }, "logos": Object { "AnimatedMark": Object { "dark": Object { @@ -3527,6 +3533,9 @@ exports[`Panels View Component renders panel view container without visualizatio ], }, "getIsVisible$": [MockFunction], + "globalSearch": Object { + "getAllSearchCommands": [MockFunction], + }, "logos": Object { "AnimatedMark": Object { "dark": Object { @@ -5313,6 +5322,9 @@ exports[`Panels View Component renders panel view container without visualizatio ], }, "getIsVisible$": [MockFunction], + "globalSearch": Object { + "getAllSearchCommands": [MockFunction], + }, "logos": Object { "AnimatedMark": Object { "dark": Object { diff --git a/public/components/custom_panels/panel_modules/panel_grid/__tests__/__snapshots__/panel_grid.test.tsx.snap b/public/components/custom_panels/panel_modules/panel_grid/__tests__/__snapshots__/panel_grid.test.tsx.snap index cd8bc1e16..7562b5821 100644 --- a/public/components/custom_panels/panel_modules/panel_grid/__tests__/__snapshots__/panel_grid.test.tsx.snap +++ b/public/components/custom_panels/panel_modules/panel_grid/__tests__/__snapshots__/panel_grid.test.tsx.snap @@ -177,6 +177,9 @@ exports[`Panel Grid Component renders panel grid component with empty visualizat ], }, "getIsVisible$": [MockFunction], + "globalSearch": Object { + "getAllSearchCommands": [MockFunction], + }, "logos": Object { "AnimatedMark": Object { "dark": Object { diff --git a/public/components/metrics/view/__tests__/__snapshots__/metrics_grid.test.tsx.snap b/public/components/metrics/view/__tests__/__snapshots__/metrics_grid.test.tsx.snap index ea4b81948..cb4832d47 100644 --- a/public/components/metrics/view/__tests__/__snapshots__/metrics_grid.test.tsx.snap +++ b/public/components/metrics/view/__tests__/__snapshots__/metrics_grid.test.tsx.snap @@ -30,6 +30,9 @@ exports[`Metrics Grid Component renders Metrics Grid Component 1`] = ` "getHelpExtension$": [MockFunction], "getIsNavDrawerLocked$": [MockFunction], "getIsVisible$": [MockFunction], + "globalSearch": Object { + "getAllSearchCommands": [MockFunction], + }, "logos": Object { "AnimatedMark": Object { "dark": Object { @@ -204,6 +207,9 @@ exports[`Metrics Grid Component renders Metrics Grid Component 1`] = ` "getHelpExtension$": [MockFunction], "getIsNavDrawerLocked$": [MockFunction], "getIsVisible$": [MockFunction], + "globalSearch": Object { + "getAllSearchCommands": [MockFunction], + }, "logos": Object { "AnimatedMark": Object { "dark": Object { diff --git a/public/components/trace_analytics/components/dashboard/__tests__/__snapshots__/dashboard.test.tsx.snap b/public/components/trace_analytics/components/dashboard/__tests__/__snapshots__/dashboard.test.tsx.snap index 979c56df4..a4f6cde40 100644 --- a/public/components/trace_analytics/components/dashboard/__tests__/__snapshots__/dashboard.test.tsx.snap +++ b/public/components/trace_analytics/components/dashboard/__tests__/__snapshots__/dashboard.test.tsx.snap @@ -33,6 +33,9 @@ exports[`Dashboard component renders dashboard 1`] = ` "getHelpExtension$": [MockFunction], "getIsNavDrawerLocked$": [MockFunction], "getIsVisible$": [MockFunction], + "globalSearch": Object { + "getAllSearchCommands": [MockFunction], + }, "logos": Object { "AnimatedMark": Object { "dark": Object { @@ -423,6 +426,9 @@ exports[`Dashboard component renders dashboard 1`] = ` "getHelpExtension$": [MockFunction], "getIsNavDrawerLocked$": [MockFunction], "getIsVisible$": [MockFunction], + "globalSearch": Object { + "getAllSearchCommands": [MockFunction], + }, "logos": Object { "AnimatedMark": Object { "dark": Object { @@ -1285,6 +1291,9 @@ exports[`Dashboard component renders empty dashboard 1`] = ` "getHelpExtension$": [MockFunction], "getIsNavDrawerLocked$": [MockFunction], "getIsVisible$": [MockFunction], + "globalSearch": Object { + "getAllSearchCommands": [MockFunction], + }, "logos": Object { "AnimatedMark": Object { "dark": Object { @@ -1674,6 +1683,9 @@ exports[`Dashboard component renders empty dashboard 1`] = ` "getHelpExtension$": [MockFunction], "getIsNavDrawerLocked$": [MockFunction], "getIsVisible$": [MockFunction], + "globalSearch": Object { + "getAllSearchCommands": [MockFunction], + }, "logos": Object { "AnimatedMark": Object { "dark": Object { @@ -2536,6 +2548,9 @@ exports[`Dashboard component renders empty jaeger dashboard 1`] = ` "getHelpExtension$": [MockFunction], "getIsNavDrawerLocked$": [MockFunction], "getIsVisible$": [MockFunction], + "globalSearch": Object { + "getAllSearchCommands": [MockFunction], + }, "logos": Object { "AnimatedMark": Object { "dark": Object { @@ -2927,6 +2942,9 @@ exports[`Dashboard component renders empty jaeger dashboard 1`] = ` "getHelpExtension$": [MockFunction], "getIsNavDrawerLocked$": [MockFunction], "getIsVisible$": [MockFunction], + "globalSearch": Object { + "getAllSearchCommands": [MockFunction], + }, "logos": Object { "AnimatedMark": Object { "dark": Object { diff --git a/public/components/trace_analytics/components/services/__tests__/__snapshots__/services.test.tsx.snap b/public/components/trace_analytics/components/services/__tests__/__snapshots__/services.test.tsx.snap index 876722ce8..705d443ed 100644 --- a/public/components/trace_analytics/components/services/__tests__/__snapshots__/services.test.tsx.snap +++ b/public/components/trace_analytics/components/services/__tests__/__snapshots__/services.test.tsx.snap @@ -33,6 +33,9 @@ exports[`Services component renders empty services page 1`] = ` "getHelpExtension$": [MockFunction], "getIsNavDrawerLocked$": [MockFunction], "getIsVisible$": [MockFunction], + "globalSearch": Object { + "getAllSearchCommands": [MockFunction], + }, "logos": Object { "AnimatedMark": Object { "dark": Object { @@ -261,6 +264,9 @@ exports[`Services component renders empty services page 1`] = ` "getHelpExtension$": [MockFunction], "getIsNavDrawerLocked$": [MockFunction], "getIsVisible$": [MockFunction], + "globalSearch": Object { + "getAllSearchCommands": [MockFunction], + }, "logos": Object { "AnimatedMark": Object { "dark": Object { @@ -2326,6 +2332,9 @@ exports[`Services component renders jaeger services page 1`] = ` "getHelpExtension$": [MockFunction], "getIsNavDrawerLocked$": [MockFunction], "getIsVisible$": [MockFunction], + "globalSearch": Object { + "getAllSearchCommands": [MockFunction], + }, "logos": Object { "AnimatedMark": Object { "dark": Object { @@ -2554,6 +2563,9 @@ exports[`Services component renders jaeger services page 1`] = ` "getHelpExtension$": [MockFunction], "getIsNavDrawerLocked$": [MockFunction], "getIsVisible$": [MockFunction], + "globalSearch": Object { + "getAllSearchCommands": [MockFunction], + }, "logos": Object { "AnimatedMark": Object { "dark": Object { @@ -4048,6 +4060,9 @@ exports[`Services component renders services page 1`] = ` "getHelpExtension$": [MockFunction], "getIsNavDrawerLocked$": [MockFunction], "getIsVisible$": [MockFunction], + "globalSearch": Object { + "getAllSearchCommands": [MockFunction], + }, "logos": Object { "AnimatedMark": Object { "dark": Object { @@ -4275,6 +4290,9 @@ exports[`Services component renders services page 1`] = ` "getHelpExtension$": [MockFunction], "getIsNavDrawerLocked$": [MockFunction], "getIsVisible$": [MockFunction], + "globalSearch": Object { + "getAllSearchCommands": [MockFunction], + }, "logos": Object { "AnimatedMark": Object { "dark": Object { diff --git a/public/components/trace_analytics/components/traces/__tests__/__snapshots__/traces.test.tsx.snap b/public/components/trace_analytics/components/traces/__tests__/__snapshots__/traces.test.tsx.snap index fdafb00fd..689ee6911 100644 --- a/public/components/trace_analytics/components/traces/__tests__/__snapshots__/traces.test.tsx.snap +++ b/public/components/trace_analytics/components/traces/__tests__/__snapshots__/traces.test.tsx.snap @@ -33,6 +33,9 @@ exports[`Traces component renders empty traces page 1`] = ` "getHelpExtension$": [MockFunction], "getIsNavDrawerLocked$": [MockFunction], "getIsVisible$": [MockFunction], + "globalSearch": Object { + "getAllSearchCommands": [MockFunction], + }, "logos": Object { "AnimatedMark": Object { "dark": Object { @@ -270,6 +273,9 @@ exports[`Traces component renders empty traces page 1`] = ` "getHelpExtension$": [MockFunction], "getIsNavDrawerLocked$": [MockFunction], "getIsVisible$": [MockFunction], + "globalSearch": Object { + "getAllSearchCommands": [MockFunction], + }, "logos": Object { "AnimatedMark": Object { "dark": Object { @@ -2513,6 +2519,9 @@ exports[`Traces component renders jaeger traces page 1`] = ` "getHelpExtension$": [MockFunction], "getIsNavDrawerLocked$": [MockFunction], "getIsVisible$": [MockFunction], + "globalSearch": Object { + "getAllSearchCommands": [MockFunction], + }, "logos": Object { "AnimatedMark": Object { "dark": Object { @@ -2750,6 +2759,9 @@ exports[`Traces component renders jaeger traces page 1`] = ` "getHelpExtension$": [MockFunction], "getIsNavDrawerLocked$": [MockFunction], "getIsVisible$": [MockFunction], + "globalSearch": Object { + "getAllSearchCommands": [MockFunction], + }, "logos": Object { "AnimatedMark": Object { "dark": Object { @@ -4832,6 +4844,9 @@ exports[`Traces component renders traces page 1`] = ` "getHelpExtension$": [MockFunction], "getIsNavDrawerLocked$": [MockFunction], "getIsVisible$": [MockFunction], + "globalSearch": Object { + "getAllSearchCommands": [MockFunction], + }, "logos": Object { "AnimatedMark": Object { "dark": Object { @@ -5068,6 +5083,9 @@ exports[`Traces component renders traces page 1`] = ` "getHelpExtension$": [MockFunction], "getIsNavDrawerLocked$": [MockFunction], "getIsVisible$": [MockFunction], + "globalSearch": Object { + "getAllSearchCommands": [MockFunction], + }, "logos": Object { "AnimatedMark": Object { "dark": Object { From 2b916633198635796038747369ab0b246db26f39 Mon Sep 17 00:00:00 2001 From: Adam Tackett Date: Mon, 14 Oct 2024 14:57:02 -0700 Subject: [PATCH 8/9] fix default selection between metrics / traces Signed-off-by: Adam Tackett --- .../getting_started_collectData.tsx | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/public/components/getting_started/components/getting_started_collectData.tsx b/public/components/getting_started/components/getting_started_collectData.tsx index 14d068048..8a69053aa 100644 --- a/public/components/getting_started/components/getting_started_collectData.tsx +++ b/public/components/getting_started/components/getting_started_collectData.tsx @@ -45,7 +45,6 @@ import { getWorkspaceIdFromUrl } from '../../../../../../src/core/public/utils'; const cardOne = 'Logs'; const cardTwo = 'Metrics'; const cardThree = 'Traces'; -const OTEL_LOGS_OPTION = { label: 'Open Telemetry', value: 'otelLogs' }; interface CollectAndShipDataProps { isOpen: boolean; @@ -71,9 +70,21 @@ export const CollectAndShipData: React.FC = ({ const [workflows, setWorkflows] = useState([]); const [collectorOptions, setCollectorOptions] = useState([]); const [patternsContent, setPatternsContent] = useState([]); + + const getTelemetryOption = (collectionMethodOtel: string) => { + switch (collectionMethodOtel) { + case cardTwo: + return { label: 'Open Telemetry', value: 'otelMetrics' }; + case cardThree: + return { label: 'Open Telemetry', value: 'otelTraces' }; + default: + return { label: 'Open Telemetry', value: 'otelLogs' }; + } + }; + const [selectedIntegration, setSelectedIntegration] = useState< Array> - >([OTEL_LOGS_OPTION]); + >([getTelemetryOption(cardOne)]); const technologyJsonMap: Record = { otelLogs: otelJsonLogs, @@ -144,7 +155,8 @@ export const CollectAndShipData: React.FC = ({ // Auto-select first collector if nothing is selected and a collection method is set useEffect(() => { if (collectorOptions.length > 0 && !specificMethod && collectionMethod) { - handleSpecificMethodChange([{ ...OTEL_LOGS_OPTION }]); + const telemetryOption = getTelemetryOption(collectionMethod); + handleSpecificMethodChange([{ ...telemetryOption }]); } }, [collectorOptions, specificMethod, collectionMethod]); @@ -157,17 +169,19 @@ export const CollectAndShipData: React.FC = ({ if (value === cardOne) { setCollectorOptions([ - { ...OTEL_LOGS_OPTION }, + getTelemetryOption(cardOne), { label: 'Nginx', value: 'nginx' }, { label: 'Java', value: 'java' }, { label: 'Python', value: 'python' }, { label: 'Golang', value: 'golang' }, ]); } else if (value === cardTwo) { - setCollectorOptions([{ label: 'Open Telemetry', value: 'otelMetrics' }]); + setCollectorOptions([getTelemetryOption(cardTwo)]); } else if (value === cardThree) { - setCollectorOptions([{ label: 'Open Telemetry', value: 'otelTraces' }]); + setCollectorOptions([getTelemetryOption(cardThree)]); } + + setSelectedIntegration([getTelemetryOption(value)]); }; const renderSpecificMethodDropdown = () => { From 5cd18d22f40e346e68a28ce6f86e27fac098bdb4 Mon Sep 17 00:00:00 2001 From: Eric Date: Mon, 14 Oct 2024 23:33:18 +0000 Subject: [PATCH 9/9] update snapshots Signed-off-by: Eric --- .../services/__tests__/__snapshots__/services.test.tsx.snap | 4 ++-- .../traces/__tests__/__snapshots__/traces.test.tsx.snap | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/public/components/trace_analytics/components/services/__tests__/__snapshots__/services.test.tsx.snap b/public/components/trace_analytics/components/services/__tests__/__snapshots__/services.test.tsx.snap index 705d443ed..3d33b9a4b 100644 --- a/public/components/trace_analytics/components/services/__tests__/__snapshots__/services.test.tsx.snap +++ b/public/components/trace_analytics/components/services/__tests__/__snapshots__/services.test.tsx.snap @@ -3127,7 +3127,7 @@ exports[`Services component renders jaeger services page 1`] = ` xmlns="http://www.w3.org/2000/svg" > @@ -4853,7 +4853,7 @@ exports[`Services component renders services page 1`] = ` xmlns="http://www.w3.org/2000/svg" > diff --git a/public/components/trace_analytics/components/traces/__tests__/__snapshots__/traces.test.tsx.snap b/public/components/trace_analytics/components/traces/__tests__/__snapshots__/traces.test.tsx.snap index 689ee6911..83b3f6fb6 100644 --- a/public/components/trace_analytics/components/traces/__tests__/__snapshots__/traces.test.tsx.snap +++ b/public/components/trace_analytics/components/traces/__tests__/__snapshots__/traces.test.tsx.snap @@ -3333,7 +3333,7 @@ exports[`Traces component renders jaeger traces page 1`] = ` xmlns="http://www.w3.org/2000/svg" > @@ -5656,7 +5656,7 @@ exports[`Traces component renders traces page 1`] = ` xmlns="http://www.w3.org/2000/svg" >