From 37421ba31930349e637222920604fa1dad6ccc53 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Wed, 1 Feb 2023 12:20:29 -0500 Subject: [PATCH] =?UTF-8?q?fix=20a=20few=20bugs=20with=20respect=20to=20re?= =?UTF-8?q?freshes=20and=20mode=20set=20via=20session=20sto=E2=80=A6=20(#1?= =?UTF-8?q?97)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix a few bugs with respect to refreshes and mode set via session storage Signed-off-by: Derek Ho * fix tests related to the change Signed-off-by: Derek Ho * pr fixes Signed-off-by: Derek Ho --------- Signed-off-by: Derek Ho --- .../__snapshots__/services.test.tsx.snap | 6 ++--- .../components/services/service_view.tsx | 22 ++++++++++++++----- .../components/services/services_content.tsx | 2 +- .../__snapshots__/traces.test.tsx.snap | 6 ++--- .../components/traces/traces_content.tsx | 2 +- public/components/trace_analytics/home.tsx | 10 +++++---- 6 files changed, 30 insertions(+), 18 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 06701fdea8..2788e3cdb3 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 @@ -1130,7 +1130,7 @@ exports[`Services component renders empty services page 1`] = ` addFilter={[Function]} dataPrepperIndicesExist={true} items={Array []} - loading={false} + loading={true} mode="data_prepper" nameColumnAction={[Function]} setRedirect={[Function]} @@ -2964,7 +2964,7 @@ exports[`Services component renders jaeger services page 1`] = ` dataPrepperIndicesExist={false} items={Array []} jaegerIndicesExist={true} - loading={false} + loading={true} mode="jaeger" nameColumnAction={[Function]} setRedirect={[Function]} @@ -4273,7 +4273,7 @@ exports[`Services component renders services page 1`] = ` addFilter={[Function]} dataPrepperIndicesExist={true} items={Array []} - loading={false} + loading={true} mode="data_prepper" nameColumnAction={[Function]} setRedirect={[Function]} diff --git a/public/components/trace_analytics/components/services/service_view.tsx b/public/components/trace_analytics/components/services/service_view.tsx index a1ce847cb2..db4c0702b4 100644 --- a/public/components/trace_analytics/components/services/service_view.tsx +++ b/public/components/trace_analytics/components/services/service_view.tsx @@ -49,7 +49,9 @@ export function ServiceView(props: ServiceViewProps) { const refresh = () => { const DSL = filtersToDsl(mode, props.filters, props.query, processTimeStamp(props.startTime, mode), processTimeStamp(props.endTime, mode)); handleServiceViewRequest(props.serviceName, props.http, DSL, setFields, mode); - handleServiceMapRequest(props.http, DSL, mode, setServiceMap, props.serviceName); + if (mode === 'data_prepper') { + handleServiceMapRequest(props.http, DSL, mode, setServiceMap, props.serviceName); + } }; useEffect(() => { @@ -233,11 +235,19 @@ export function ServiceView(props: ServiceViewProps) { useEffect(() => { const spanDSL = filtersToDsl(mode, props.filters, props.query, processTimeStamp(props.startTime, mode), processTimeStamp(props.endTime, mode)); - spanDSL.query.bool.must.push({ - term: { - "process.serviceName": props.serviceName, - }, - }); + if (mode === 'data_prepper') { + spanDSL.query.bool.must.push({ + term: { + "serviceName": props.serviceName, + }, + }); + } else if (mode === 'jaeger') { + spanDSL.query.bool.must.push({ + term: { + "process.serviceName": props.serviceName, + }, + }); + } spanFilters.map(({ field, value }) => { if (value != null) { spanDSL.query.bool.must.push({ diff --git a/public/components/trace_analytics/components/services/services_content.tsx b/public/components/trace_analytics/components/services/services_content.tsx index 9a977bea18..e25bf8726f 100644 --- a/public/components/trace_analytics/components/services/services_content.tsx +++ b/public/components/trace_analytics/components/services/services_content.tsx @@ -72,7 +72,7 @@ export function ServicesContent(props: ServicesProps) { } setFilteredService(newFilteredService); if (!redirect && ((mode === 'data_prepper' && dataPrepperIndicesExist) || (mode === 'jaeger' && jaegerIndicesExist))) refresh(newFilteredService); - }, [filters, appConfigs]); + }, [filters, appConfigs, redirect, mode, jaegerIndicesExist, dataPrepperIndicesExist]); const refresh = async (currService?: string) => { setLoading(true); 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 e08fbaf1c5..bc0e6270e5 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 @@ -1127,7 +1127,7 @@ exports[`Traces component renders empty traces page 1`] = ` { if (!redirect && ((mode === 'data_prepper' && dataPrepperIndicesExist) || (mode === 'jaeger' && jaegerIndicesExist))) refresh(); - }, [filters, appConfigs]); + }, [filters, appConfigs, redirect, mode, dataPrepperIndicesExist, jaegerIndicesExist]); const refresh = async (sort?: PropertySort) => { setLoading(true); diff --git a/public/components/trace_analytics/home.tsx b/public/components/trace_analytics/home.tsx index d515f26ad3..3e154010d4 100644 --- a/public/components/trace_analytics/home.tsx +++ b/public/components/trace_analytics/home.tsx @@ -92,10 +92,12 @@ export const Home = (props: HomeProps) => { ]; useEffect(() => { - if (dataPrepperIndicesExist) { - setMode('data_prepper'); - } else if (jaegerIndicesExist) { - setMode('jaeger'); + if (!sessionStorage.getItem('TraceAnalyticsMode')){ + if (dataPrepperIndicesExist) { + setMode('data_prepper'); + } else if (jaegerIndicesExist) { + setMode('jaeger'); + } } }, [jaegerIndicesExist, dataPrepperIndicesExist]);