From 5da577f4d253636a10cf99e1f14e53acac2c2170 Mon Sep 17 00:00:00 2001 From: Sumukh Swamy Date: Mon, 29 Jul 2024 16:50:37 -0700 Subject: [PATCH] [Bug] Trace Analytics bug fix for local cluster being rendered (#2006) * traces and app analytics fix Signed-off-by: sumukhswamy * reverted json file Signed-off-by: sumukhswamy * updated snapshots Signed-off-by: sumukhswamy --------- Signed-off-by: sumukhswamy --- .../components/application.tsx | 42 ++++---- .../__snapshots__/search.test.tsx.snap | 6 +- .../custom_panel_view.test.tsx.snap | 18 +++- .../__snapshots__/top_menu.test.tsx.snap | 9 +- .../__snapshots__/search_bar.test.tsx.snap | 12 ++- .../__snapshots__/service_view.test.tsx.snap | 1 + .../__snapshots__/services.test.tsx.snap | 18 +++- .../__snapshots__/traces.test.tsx.snap | 18 +++- .../components/traces/traces_content.tsx | 16 --- public/components/trace_analytics/home.tsx | 98 ++++++++++--------- 10 files changed, 145 insertions(+), 93 deletions(-) diff --git a/public/components/application_analytics/components/application.tsx b/public/components/application_analytics/components/application.tsx index bb6fa8e1f5..27b5dd2319 100644 --- a/public/components/application_analytics/components/application.tsx +++ b/public/components/application_analytics/components/application.tsx @@ -18,23 +18,14 @@ import { EuiText, EuiTitle, } from '@elastic/eui'; +import { VisualizationType } from 'common/types/custom_panels'; import DSLService from 'public/services/requests/dsl'; import PPLService from 'public/services/requests/ppl'; import SavedObjects from 'public/services/saved_objects/event_analytics/saved_objects'; import TimestampUtils from 'public/services/timestamp/timestamp'; import React, { ReactChild, useEffect, useState } from 'react'; -import { useHistory } from 'react-router-dom'; import { useDispatch } from 'react-redux'; -import { VisualizationType } from 'common/types/custom_panels'; -import { TracesContent } from '../../../components/trace_analytics/components/traces/traces_content'; -import { ServicesContent } from '../../trace_analytics/components/services/services_content'; -import { - filtersToDsl, - PanelTitle, -} from '../../../../public/components/trace_analytics/components/common/helper_functions'; -import { SpanDetailTable } from '../../../../public/components/trace_analytics/components/traces/span_detail_table'; -import { Explorer } from '../../event_analytics/explorer/explorer'; -import { Configuration } from './configuration'; +import { useHistory } from 'react-router-dom'; import { TAB_CONFIG_ID, TAB_CONFIG_TITLE, @@ -48,22 +39,30 @@ import { TAB_TRACE_ID, TAB_TRACE_TITLE, } from '../../../../common/constants/application_analytics'; -import { TAB_EVENT_ID, TAB_CHART_ID, NEW_TAB } from '../../../../common/constants/explorer'; -import { IQueryTab } from '../../../../common/types/explorer'; -import { NotificationsStart, Toast } from '../../../../../../src/core/public'; -import { AppAnalyticsComponentDeps } from '../home'; -import { CustomPanelView } from '../../../../public/components/custom_panels/custom_panel_view'; +import { CUSTOM_PANELS_API_PREFIX } from '../../../../common/constants/custom_panels'; +import { NEW_TAB, TAB_CHART_ID, TAB_EVENT_ID } from '../../../../common/constants/explorer'; +import { QueryManager } from '../../../../common/query_manager/ppl_query_manager'; import { ApplicationRequestType, ApplicationType, } from '../../../../common/types/application_analytics'; -import { CUSTOM_PANELS_API_PREFIX } from '../../../../common/constants/custom_panels'; -import { ServiceDetailFlyout } from './flyout_components/service_detail_flyout'; +import { IQueryTab } from '../../../../common/types/explorer'; +import { setNavBreadCrumbs } from '../../../../common/utils/set_nav_bread_crumbs'; +import { CustomPanelView } from '../../../../public/components/custom_panels/custom_panel_view'; +import { + filtersToDsl, + PanelTitle, +} from '../../../../public/components/trace_analytics/components/common/helper_functions'; import { SpanDetailFlyout } from '../../../../public/components/trace_analytics/components/traces/span_detail_flyout'; -import { TraceDetailFlyout } from './flyout_components/trace_detail_flyout'; +import { SpanDetailTable } from '../../../../public/components/trace_analytics/components/traces/span_detail_table'; +import { TracesContent } from '../../../components/trace_analytics/components/traces/traces_content'; +import { Explorer } from '../../event_analytics/explorer/explorer'; +import { ServicesContent } from '../../trace_analytics/components/services/services_content'; import { fetchAppById, initializeTabData } from '../helpers/utils'; -import { QueryManager } from '../../../../common/query_manager/ppl_query_manager'; -import { setNavBreadCrumbs } from '../../../../common/utils/set_nav_bread_crumbs'; +import { AppAnalyticsComponentDeps } from '../home'; +import { Configuration } from './configuration'; +import { ServiceDetailFlyout } from './flyout_components/service_detail_flyout'; +import { TraceDetailFlyout } from './flyout_components/trace_detail_flyout'; const searchBarConfigs = { [TAB_EVENT_ID]: { @@ -302,6 +301,7 @@ export function Application(props: AppDetailProps) { endTime={appEndTime} setStartTime={setStartTimeForApp} setEndTime={setEndTimeForApp} + dataSourceMDSId={[{ id: '', label: '' }]} /> ); diff --git a/public/components/common/search/__tests__/__snapshots__/search.test.tsx.snap b/public/components/common/search/__tests__/__snapshots__/search.test.tsx.snap index ef20b90549..3991cb057d 100644 --- a/public/components/common/search/__tests__/__snapshots__/search.test.tsx.snap +++ b/public/components/common/search/__tests__/__snapshots__/search.test.tsx.snap @@ -395,6 +395,7 @@ exports[`Explorer Search component renders basic component 1`] = ` }, ] } + compressed={false} data-test-subj="pplSearchDatePicker" dateFormat="" end="now" @@ -423,6 +424,7 @@ exports[`Explorer Search component renders basic component 1`] = ` > - + 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 baaddbe169..cfd039fcff 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 @@ -1979,6 +1979,7 @@ exports[`Panels View Component renders panel view container with visualizations }, ] } + compressed={false} dateFormat="" end="now" isAutoRefreshOnly={false} @@ -2005,6 +2006,7 @@ exports[`Panels View Component renders panel view container with visualizations > - + @@ -2315,6 +2319,7 @@ exports[`Panels View Component renders panel view container with visualizations className="euiFlexItem euiFlexItem--flexGrowZero" > - + @@ -4564,6 +4575,7 @@ exports[`Panels View Component renders panel view container without visualizatio className="euiFlexItem euiFlexItem--flexGrowZero" > - + @@ -676,6 +680,7 @@ exports[`Metrics Top Menu Component renders Top Menu Component when enabled 1`] className="euiFlexItem euiFlexItem--flexGrowZero" > - + @@ -555,6 +559,7 @@ exports[`Search bar components renders search bar 1`] = ` }, ] } + compressed={false} dateFormat="" end="now" isAutoRefreshOnly={false} @@ -581,6 +586,7 @@ exports[`Search bar components renders search bar 1`] = ` > - + diff --git a/public/components/trace_analytics/components/services/__tests__/__snapshots__/service_view.test.tsx.snap b/public/components/trace_analytics/components/services/__tests__/__snapshots__/service_view.test.tsx.snap index c8aac88123..9f577a7521 100644 --- a/public/components/trace_analytics/components/services/__tests__/__snapshots__/service_view.test.tsx.snap +++ b/public/components/trace_analytics/components/services/__tests__/__snapshots__/service_view.test.tsx.snap @@ -67,6 +67,7 @@ exports[`Service view component renders service view 1`] = ` }, ] } + compressed={false} dateFormat="" end="now" isAutoRefreshOnly={false} 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 0e0d8e2d25..71f193d6e1 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 @@ -764,6 +764,7 @@ exports[`Services component renders empty services page 1`] = ` }, ] } + compressed={false} dateFormat="" end="now" isAutoRefreshOnly={false} @@ -790,6 +791,7 @@ exports[`Services component renders empty services page 1`] = ` > - + @@ -2971,6 +2975,7 @@ exports[`Services component renders jaeger services page 1`] = ` }, ] } + compressed={false} dateFormat="" end="now" isAutoRefreshOnly={false} @@ -2997,6 +3002,7 @@ exports[`Services component renders jaeger services page 1`] = ` > - + @@ -4609,6 +4617,7 @@ exports[`Services component renders services page 1`] = ` }, ] } + compressed={false} dateFormat="" end="now" isAutoRefreshOnly={false} @@ -4635,6 +4644,7 @@ exports[`Services component renders services page 1`] = ` > - + 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 06dab9e405..15c83154e1 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 @@ -782,6 +782,7 @@ exports[`Traces component renders empty traces page 1`] = ` }, ] } + compressed={false} dateFormat="" end="now" isAutoRefreshOnly={false} @@ -808,6 +809,7 @@ exports[`Traces component renders empty traces page 1`] = ` > - + @@ -2460,6 +2464,7 @@ exports[`Traces component renders jaeger traces page 1`] = ` }, ] } + compressed={false} dateFormat="" end="now" isAutoRefreshOnly={false} @@ -2486,6 +2491,7 @@ exports[`Traces component renders jaeger traces page 1`] = ` > - + @@ -4141,6 +4149,7 @@ exports[`Traces component renders traces page 1`] = ` }, ] } + compressed={false} dateFormat="" end="now" isAutoRefreshOnly={false} @@ -4167,6 +4176,7 @@ exports[`Traces component renders traces page 1`] = ` > - + diff --git a/public/components/trace_analytics/components/traces/traces_content.tsx b/public/components/trace_analytics/components/traces/traces_content.tsx index d88f0f8fe4..35039cbb02 100644 --- a/public/components/trace_analytics/components/traces/traces_content.tsx +++ b/public/components/trace_analytics/components/traces/traces_content.tsx @@ -6,8 +6,6 @@ import { EuiAccordion, EuiPanel, EuiSpacer, PropertySort } from '@elastic/eui'; import React, { useEffect, useState } from 'react'; -import { DataSourceViewConfig } from '../../../../../../../src/plugins/data_source_management/public'; -import { dataSourceFilterFn } from '../../../../../common/utils/shared'; import { coreRefs } from '../../../../framework/core_refs'; import { handleTracesRequest } from '../../requests/traces_request_handler'; import { getValidFilterFields } from '../common/filters/filter_helpers'; @@ -36,8 +34,6 @@ export function TracesContent(props: TracesProps) { mode, dataPrepperIndicesExist, jaegerIndicesExist, - dataSourceManagement, - dataSourceMDSId, attributesFilterFields, } = props; const [tableItems, setTableItems] = useState([]); @@ -45,7 +41,6 @@ export function TracesContent(props: TracesProps) { const [loading, setLoading] = useState(false); const [trigger, setTrigger] = useState<'open' | 'closed'>('closed'); const isNavGroupEnabled = coreRefs?.chrome?.navGroup.getNavGroupEnabled(); - const DataSourceMenu = dataSourceManagement?.ui?.getDataSourceMenu(); useEffect(() => { chrome.setBreadcrumbs([ @@ -114,17 +109,6 @@ export function TracesContent(props: TracesProps) { return ( <> - {props.dataSourceEnabled && ( - - )} { const { chrome } = props; const isNavGroupEnabled = chrome.navGroup.getNavGroupEnabled(); + const DataSourceMenu = props.dataSourceManagement?.ui?.getDataSourceMenu< + DataSourceSelectableConfig + >(); + + const onSelectedDataSource = (e) => { + const dataConnectionId = e[0] ? e[0].id : undefined; + const dataConnectionLabel = e[0] ? e[0].label : undefined; + + setDataSourceMDSId([{ id: dataConnectionId, label: dataConnectionLabel }]); + }; + + const dataSourceMenuComponent = useMemo(() => { + return ( + + ); + }, [props.setActionMenu, props.savedObjectsMDSClient.client, props.notifications]); + useEffect(() => { handleDataPrepperIndicesExistRequest( props.http, @@ -248,17 +274,6 @@ export const Home = (props: HomeProps) => { setSpanFlyout, }; - const onSelectedDataSource = async (dataSources: DataSourceOption[]) => { - const { id = '', label = '' } = dataSources[0] || {}; - if (dataSourceMDSId[0].id !== id || dataSourceMDSId[0].label !== label) { - setDataSourceMDSId([{ id, label }]); - } - }; - - const DataSourceMenu = props.dataSourceManagement?.ui?.getDataSourceMenu< - DataSourceSelectableConfig - >(); - let flyout; if (currentSelectedService !== '') { @@ -274,20 +289,6 @@ export const Home = (props: HomeProps) => { return ( <> - {props.dataSourceEnabled && ( - - )} { @@ -302,6 +303,7 @@ export const Home = (props: HomeProps) => { render={(_routerProps) => !isNavGroupEnabled ? ( + {props.dataSourceEnabled && dataSourceMenuComponent} { /> ) : ( - + <> + {props.dataSourceEnabled && dataSourceMenuComponent} + + + ) } /> @@ -347,6 +353,7 @@ export const Home = (props: HomeProps) => { render={(_routerProps) => !isNavGroupEnabled ? ( + {props.dataSourceEnabled && dataSourceMenuComponent} { /> ) : ( - + <> + {props.dataSourceEnabled && dataSourceMenuComponent} + + ) } />