Skip to content

Commit

Permalink
fix a few bugs with respect to refreshes and mode set via session sto… (
Browse files Browse the repository at this point in the history
#197) (#238)

* fix a few bugs with respect to refreshes and mode set via session storage

Signed-off-by: Derek Ho <dxho@amazon.com>

* fix tests related to the change

Signed-off-by: Derek Ho <dxho@amazon.com>

* pr fixes

Signed-off-by: Derek Ho <dxho@amazon.com>

---------

Signed-off-by: Derek Ho <dxho@amazon.com>
(cherry picked from commit 37421ba)

Co-authored-by: Derek Ho <dxho@amazon.com>
  • Loading branch information
opensearch-trigger-bot[bot] and derek-ho authored Feb 6, 2023
1 parent d2ca1b6 commit 5532041
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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]}
Expand Down Expand Up @@ -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]}
Expand Down Expand Up @@ -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]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down Expand Up @@ -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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,7 @@ exports[`Traces component renders empty traces page 1`] = `
<TracesTable
dataPrepperIndicesExist={true}
items={Array []}
loading={false}
loading={true}
mode="data_prepper"
refresh={[Function]}
traceIdColumnAction={[Function]}
Expand Down Expand Up @@ -2427,7 +2427,7 @@ exports[`Traces component renders jaeger traces page 1`] = `
dataPrepperIndicesExist={false}
items={Array []}
jaegerIndicesExist={true}
loading={false}
loading={true}
mode="jaeger"
refresh={[Function]}
traceIdColumnAction={[Function]}
Expand Down Expand Up @@ -3724,7 +3724,7 @@ exports[`Traces component renders traces page 1`] = `
<TracesTable
dataPrepperIndicesExist={true}
items={Array []}
loading={false}
loading={true}
mode="data_prepper"
refresh={[Function]}
traceIdColumnAction={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function TracesContent(props: TracesProps) {

useEffect(() => {
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);
Expand Down
10 changes: 6 additions & 4 deletions public/components/trace_analytics/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down

0 comments on commit 5532041

Please sign in to comment.