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] Trace Groups Optimization - Remove duplicate filters #2373

Merged
merged 1 commit into from
Mar 5, 2025
Merged
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
Trace Groups Optimization - Remove duplicate filters (#2368)
* trace group opt, remove duplicate filter calls

Signed-off-by: Adam Tackett <tackadam@amazon.com>

* add back validation for traces and services, keep it removed for dashboard content

Signed-off-by: Adam Tackett <tackadam@amazon.com>

* remove spacing

Signed-off-by: Adam Tackett <tackadam@amazon.com>

* fix bug for filter applied from trace group

Signed-off-by: Adam Tackett <tackadam@amazon.com>

---------

Signed-off-by: Adam Tackett <tackadam@amazon.com>
Co-authored-by: Adam Tackett <tackadam@amazon.com>
(cherry picked from commit b84c5db)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
github-actions[bot] and Adam Tackett committed Mar 4, 2025
commit 5a8a4394a0780446ecc1428e6cc084f28bd871e5
Original file line number Diff line number Diff line change
@@ -222,21 +222,7 @@ exports[`Dashboard component renders dashboard 1`] = `
}
query=""
setEndTime={[MockFunction]}
setFilters={
[MockFunction] {
"calls": Array [
Array [
Array [],
],
],
"results": Array [
Object {
"type": "return",
"value": undefined,
},
],
}
}
setFilters={[MockFunction]}
setQuery={[MockFunction]}
setStartTime={[MockFunction]}
startTime="now-5m"
@@ -617,21 +603,7 @@ exports[`Dashboard component renders dashboard 1`] = `
}
query=""
setEndTime={[MockFunction]}
setFilters={
[MockFunction] {
"calls": Array [
Array [
Array [],
],
],
"results": Array [
Object {
"type": "return",
"value": undefined,
},
],
}
}
setFilters={[MockFunction]}
setQuery={[MockFunction]}
setStartTime={[MockFunction]}
startTime="now-5m"
@@ -2870,21 +2842,7 @@ exports[`Dashboard component renders empty dashboard 1`] = `
}
query=""
setEndTime={[MockFunction]}
setFilters={
[MockFunction] {
"calls": Array [
Array [
Array [],
],
],
"results": Array [
Object {
"type": "return",
"value": undefined,
},
],
}
}
setFilters={[MockFunction]}
setQuery={[MockFunction]}
setStartTime={[MockFunction]}
startTime="now-5m"
@@ -3264,21 +3222,7 @@ exports[`Dashboard component renders empty dashboard 1`] = `
}
query=""
setEndTime={[MockFunction]}
setFilters={
[MockFunction] {
"calls": Array [
Array [
Array [],
],
],
"results": Array [
Object {
"type": "return",
"value": undefined,
},
],
}
}
setFilters={[MockFunction]}
setQuery={[MockFunction]}
setStartTime={[MockFunction]}
startTime="now-5m"
@@ -5517,21 +5461,7 @@ exports[`Dashboard component renders empty jaeger dashboard 1`] = `
}
query=""
setEndTime={[MockFunction]}
setFilters={
[MockFunction] {
"calls": Array [
Array [
Array [],
],
],
"results": Array [
Object {
"type": "return",
"value": undefined,
},
],
}
}
setFilters={[MockFunction]}
setQuery={[MockFunction]}
setStartTime={[MockFunction]}
startTime="now-5m"
@@ -5913,21 +5843,7 @@ exports[`Dashboard component renders empty jaeger dashboard 1`] = `
}
query=""
setEndTime={[MockFunction]}
setFilters={
[MockFunction] {
"calls": Array [
Array [
Array [],
],
],
"results": Array [
Object {
"type": "return",
"value": undefined,
},
],
}
}
setFilters={[MockFunction]}
setQuery={[MockFunction]}
setStartTime={[MockFunction]}
startTime="now-5m"
Original file line number Diff line number Diff line change
@@ -17,7 +17,6 @@
handleJaegerDashboardRequest,
handleJaegerErrorDashboardRequest,
} from '../../requests/dashboard_request_handler';
import { getValidFilterFields } from '../common/filters/filter_helpers';
import { FilterType } from '../common/filters/filters';
import {
MissingConfigurationMessage,
@@ -47,14 +46,13 @@
filters,
setStartTime,
setEndTime,
setQuery,

Check failure on line 49 in public/components/trace_analytics/components/dashboard/dashboard_content.tsx

GitHub Actions / Lint

'setQuery' is assigned a value but never used. Allowed unused vars must match /^_/u
setFilters,
mode,
dataPrepperIndicesExist,
jaegerIndicesExist,
toasts,
dataSourceMDSId,
attributesFilterFields,
} = props;
const [tableItems, setTableItems] = useState([]);
const [jaegerTableItems, setJaegerTableItems] = useState([]);
@@ -62,7 +60,7 @@
const [throughputPltItems, setThroughputPltItems] = useState({ items: [], fixedInterval: '1h' });
const [errorRatePltItems, setErrorRatePltItems] = useState({ items: [], fixedInterval: '1h' });
const [percentileMap, setPercentileMap] = useState<{ [traceGroup: string]: number[] }>({});
const [filteredService, setFilteredService] = useState('');

Check failure on line 63 in public/components/trace_analytics/components/dashboard/dashboard_content.tsx

GitHub Actions / Lint

'filteredService' is assigned a value but never used. Allowed unused vars must match /^_/u

Check failure on line 63 in public/components/trace_analytics/components/dashboard/dashboard_content.tsx

GitHub Actions / Lint

'setFilteredService' is assigned a value but never used. Allowed unused vars must match /^_/u
const [redirect, setRedirect] = useState(true);
const [isTraceGroupTableLoading, setIsTraceGroupTableLoading] = useState(false);
const [showTimeoutToast, setShowTimeoutToast] = useState(false);
@@ -89,13 +87,6 @@
chrome.setBreadcrumbs([parentBreadcrumb, ...childBreadcrumbs]);
}

const validFilters = getValidFilterFields(mode, page, attributesFilterFields);
setFilters([
...filters.map((filter) => ({
...filter,
locked: validFilters.indexOf(filter.field) === -1,
})),
]);
setRedirect(false);
}, []);

@@ -195,7 +186,7 @@
// service map should not be filtered by service name (https://github.com/opensearch-project/observability/issues/442)
const serviceMapDSL = _.cloneDeep(DSL);
serviceMapDSL.query.bool.must = serviceMapDSL.query.bool.must.filter(
(must: any) => must?.term?.serviceName == null

Check warning on line 189 in public/components/trace_analytics/components/dashboard/dashboard_content.tsx

GitHub Actions / Lint

Unexpected any. Specify a different type
);
}

@@ -247,8 +238,8 @@
for (let i = 0; i < filters.length; i++) {
if (filters[i].custom) {
const newFilter = JSON.parse(JSON.stringify(filters[i]));
newFilter.custom.query.bool.should.forEach((should: any) =>

Check warning on line 241 in public/components/trace_analytics/components/dashboard/dashboard_content.tsx

GitHub Actions / Lint

Unexpected any. Specify a different type
should.bool.must.forEach((must: any) => {

Check warning on line 242 in public/components/trace_analytics/components/dashboard/dashboard_content.tsx

GitHub Actions / Lint

Unexpected any. Specify a different type
const range = must?.range?.['traceGroupFields.durationInNanos'];
if (range) {
const duration = range.lt || range.lte || range.gt || range.gte;
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@

export function DashboardTable(props: {
title?: string;
items: any[];

Check warning on line 31 in public/components/trace_analytics/components/dashboard/dashboard_table.tsx

GitHub Actions / Lint

Unexpected any. Specify a different type
filters: FilterType[];
addFilter: (filter: FilterType) => void;
addPercentileFilter: (condition?: 'gte' | 'lte', additionalFilters?: FilterType[]) => void;
@@ -36,7 +36,7 @@
loading: boolean;
page: 'dashboard' | 'traces' | 'services' | 'app';
}) {
const getVarianceProps = (items: any[]) => {

Check warning on line 39 in public/components/trace_analytics/components/dashboard/dashboard_table.tsx

GitHub Actions / Lint

Unexpected any. Specify a different type
if (items.length === 0) {
return { minRange: 0, maxRange: 0, ticks: [0, 0], scale: '' };
}
@@ -335,7 +335,7 @@
inverted: false,
disabled: false,
});
if (props.page !== 'app') {
if (!['app', 'traces'].includes(props.page)) {
props.setRedirect(true);
location.assign('#/traces');
}
@@ -345,7 +345,7 @@
</EuiLink>
),
},
] as Array<EuiTableFieldDataColumnType<any>>;

Check warning on line 348 in public/components/trace_analytics/components/dashboard/dashboard_table.tsx

GitHub Actions / Lint

Unexpected any. Specify a different type

const renderTitleBar = (totalItems: number) => {
return (
@@ -380,8 +380,8 @@
};

const varianceProps = useMemo(() => getVarianceProps(props.items), [props.items]);
const columns = useMemo(() => getColumns(), [props.items, props.filters]);

Check warning on line 383 in public/components/trace_analytics/components/dashboard/dashboard_table.tsx

GitHub Actions / Lint

React Hook useMemo has a missing dependency: 'getColumns'. Either include it or remove the dependency array
const titleBar = useMemo(() => renderTitleBar(props.items?.length), [props.items]);

Check warning on line 384 in public/components/trace_analytics/components/dashboard/dashboard_table.tsx

GitHub Actions / Lint

React Hook useMemo has a missing dependency: 'renderTitleBar'. Either include it or remove the dependency array

const [sorting, setSorting] = useState<{ sort: PropertySort }>({
sort: {
@@ -390,7 +390,7 @@
},
});

const onTableChange = async ({ _page, sort }: CriteriaWithPagination<any>) => {

Check warning on line 393 in public/components/trace_analytics/components/dashboard/dashboard_table.tsx

GitHub Actions / Lint

Unexpected any. Specify a different type
if (typeof sort?.field !== 'string') return;
setSorting({ sort } as { sort: PropertySort });
};