Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.x] fix a few bugs with respect to refreshes and mode set via session sto… #237

Merged
merged 1 commit into from
Feb 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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