From 9b06811f37407e54736678f53e0cfcc9691839f9 Mon Sep 17 00:00:00 2001 From: Ansh Goyal Date: Sun, 10 Dec 2023 20:21:30 +0530 Subject: [PATCH 1/5] add ld submd Signed-off-by: Ansh Goyal --- .../TraceStatistics/generateDropdownValue.tsx | 20 +++++++------- .../TracePage/TraceStatistics/tableValues.tsx | 26 +++++++++++-------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/packages/jaeger-ui/src/components/TracePage/TraceStatistics/generateDropdownValue.tsx b/packages/jaeger-ui/src/components/TracePage/TraceStatistics/generateDropdownValue.tsx index 21e8158925..d2cc4eb661 100644 --- a/packages/jaeger-ui/src/components/TracePage/TraceStatistics/generateDropdownValue.tsx +++ b/packages/jaeger-ui/src/components/TracePage/TraceStatistics/generateDropdownValue.tsx @@ -12,7 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -import _ from 'lodash'; +import _map from 'lodash/map'; +import _flatten from 'lodash/flatten'; +import _uniq from 'lodash/uniq'; +import _filter from 'lodash/filter'; +import _concat from 'lodash/concat'; import { Trace } from '../../../types/trace'; import { ITableSpan } from './types'; @@ -41,11 +45,9 @@ function getValueTagIsPicked(tableValue: ITableSpan[], trace: Trace, nameSelecto } availableTags = [...new Set(availableTags)]; - const tags = _(availableTags).map('tags').flatten().value(); - let tagKeys = _(tags).map('key').uniq().value(); - tagKeys = _.filter(tagKeys, function calc(o) { - return o !== nameSelectorTitle; - }); + const tags = _map(availableTags, 'tags'); + let tagKeys = _uniq(_map(_flatten(tags), 'key')); + tagKeys = _filter(tagKeys, o => o !== nameSelectorTitle); availableTags = []; availableTags.push(serviceName); availableTags.push(operationName); @@ -77,9 +79,9 @@ function getValueNoTagIsPicked(trace: Trace, nameSelectorTitle: string) { export function generateDropdownValue(trace: Trace) { const allSpans = trace.spans; - const tags = _(allSpans).map('tags').flatten().value(); - const tagKeys = _(tags).map('key').uniq().value(); - const values = _.concat(serviceName, operationName, tagKeys); + const tags = _flatten(_map(allSpans, 'tags')); + const tagKeys = _uniq(_map(tags, 'key')); + const values = _concat(serviceName, operationName, tagKeys); return values; } diff --git a/packages/jaeger-ui/src/components/TracePage/TraceStatistics/tableValues.tsx b/packages/jaeger-ui/src/components/TracePage/TraceStatistics/tableValues.tsx index 62d84f02e9..26dfcb3d49 100644 --- a/packages/jaeger-ui/src/components/TracePage/TraceStatistics/tableValues.tsx +++ b/packages/jaeger-ui/src/components/TracePage/TraceStatistics/tableValues.tsx @@ -13,7 +13,9 @@ // limitations under the License. import memoizeOne from 'memoize-one'; -import * as _ from 'lodash'; +import _groupBy from 'lodash/groupBy'; +import _uniq from 'lodash/uniq'; +import _map from 'lodash/map'; import DRange from 'drange'; import { Trace, Span } from '../../../types/trace'; import { ITableSpan } from './types'; @@ -115,20 +117,22 @@ function valueFirstDropdown(selectedTagKey: string, trace: Trace) { const allSpans = trace.spans; // all possibilities that can be displayed if (selectedTagKey === serviceName) { - const temp = _.chain(allSpans) - .groupBy(x => x.process.serviceName) - .map((value, key) => ({ key })) - .uniq() - .value(); + const temp = _uniq( + _map( + _groupBy(allSpans, x => x.process.serviceName), + (value, key) => ({ key }) + ) + ); for (let i = 0; i < temp.length; i++) { allDiffColumnValues.push(temp[i].key); } } else if (selectedTagKey === operationName) { - const temp = _.chain(allSpans) - .groupBy(x => x.operationName) - .map((value, key) => ({ key })) - .uniq() - .value(); + const temp = _uniq( + _map( + _groupBy(allSpans, x => x.operationName), + (value, key) => ({ key }) + ) + ); for (let i = 0; i < temp.length; i++) { allDiffColumnValues.push(temp[i].key); } From eb4546d97ceae783900e3b7d5883e27e3f24c01d Mon Sep 17 00:00:00 2001 From: Ansh Goyal Date: Mon, 11 Dec 2023 08:43:01 +0530 Subject: [PATCH 2/5] fix lodash syntax Signed-off-by: Ansh Goyal --- .../TracePage/TraceStatistics/tableValues.tsx | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/packages/jaeger-ui/src/components/TracePage/TraceStatistics/tableValues.tsx b/packages/jaeger-ui/src/components/TracePage/TraceStatistics/tableValues.tsx index 26dfcb3d49..2d5c5fd1ed 100644 --- a/packages/jaeger-ui/src/components/TracePage/TraceStatistics/tableValues.tsx +++ b/packages/jaeger-ui/src/components/TracePage/TraceStatistics/tableValues.tsx @@ -13,8 +13,7 @@ // limitations under the License. import memoizeOne from 'memoize-one'; -import _groupBy from 'lodash/groupBy'; -import _uniq from 'lodash/uniq'; +import _uniqBy from 'lodash/uniqBy'; import _map from 'lodash/map'; import DRange from 'drange'; import { Trace, Span } from '../../../types/trace'; @@ -117,21 +116,17 @@ function valueFirstDropdown(selectedTagKey: string, trace: Trace) { const allSpans = trace.spans; // all possibilities that can be displayed if (selectedTagKey === serviceName) { - const temp = _uniq( - _map( - _groupBy(allSpans, x => x.process.serviceName), - (value, key) => ({ key }) - ) + const temp = _map( + _uniqBy(allSpans, x => x.process.serviceName), + x => ({ key: x.process.serviceName }) ); for (let i = 0; i < temp.length; i++) { allDiffColumnValues.push(temp[i].key); } } else if (selectedTagKey === operationName) { - const temp = _uniq( - _map( - _groupBy(allSpans, x => x.operationName), - (value, key) => ({ key }) - ) + const temp = _map( + _uniqBy(allSpans, x => x.operationName), + x => ({ key: x.operationName }) ); for (let i = 0; i < temp.length; i++) { allDiffColumnValues.push(temp[i].key); From cf5fe526392cf1cf73b925296893a7c8cd35c997 Mon Sep 17 00:00:00 2001 From: Ansh Goyal Date: Mon, 11 Dec 2023 08:44:34 +0530 Subject: [PATCH 3/5] fix lodash syntax Signed-off-by: Ansh Goyal --- .../TracePage/TraceStatistics/generateDropdownValue.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/jaeger-ui/src/components/TracePage/TraceStatistics/generateDropdownValue.tsx b/packages/jaeger-ui/src/components/TracePage/TraceStatistics/generateDropdownValue.tsx index d2cc4eb661..810d3fbad1 100644 --- a/packages/jaeger-ui/src/components/TracePage/TraceStatistics/generateDropdownValue.tsx +++ b/packages/jaeger-ui/src/components/TracePage/TraceStatistics/generateDropdownValue.tsx @@ -46,12 +46,12 @@ function getValueTagIsPicked(tableValue: ITableSpan[], trace: Trace, nameSelecto availableTags = [...new Set(availableTags)]; const tags = _map(availableTags, 'tags'); - let tagKeys = _uniq(_map(_flatten(tags), 'key')); - tagKeys = _filter(tagKeys, o => o !== nameSelectorTitle); + let spansWithFilterTag = _uniq(_map(_flatten(tags), 'key')); + spansWithFilterTag = _filter(spansWithFilterTag, o => o !== nameSelectorTitle); availableTags = []; availableTags.push(serviceName); availableTags.push(operationName); - availableTags = availableTags.concat(tagKeys); + availableTags = availableTags.concat(spansWithFilterTag); return availableTags; } From b6ea0db6c41dd686081b56c3563d0fd0c13d49a8 Mon Sep 17 00:00:00 2001 From: Ansh Goyal Date: Mon, 11 Dec 2023 22:35:32 +0530 Subject: [PATCH 4/5] use js syntax Signed-off-by: Ansh Goyal --- .../TraceStatistics/generateDropdownValue.tsx | 37 +++++++++---------- .../TracePage/TraceStatistics/tableValues.tsx | 19 ++-------- 2 files changed, 21 insertions(+), 35 deletions(-) diff --git a/packages/jaeger-ui/src/components/TracePage/TraceStatistics/generateDropdownValue.tsx b/packages/jaeger-ui/src/components/TracePage/TraceStatistics/generateDropdownValue.tsx index 810d3fbad1..659b1c73ee 100644 --- a/packages/jaeger-ui/src/components/TracePage/TraceStatistics/generateDropdownValue.tsx +++ b/packages/jaeger-ui/src/components/TracePage/TraceStatistics/generateDropdownValue.tsx @@ -15,7 +15,6 @@ import _map from 'lodash/map'; import _flatten from 'lodash/flatten'; import _uniq from 'lodash/uniq'; -import _filter from 'lodash/filter'; import _concat from 'lodash/concat'; import { Trace } from '../../../types/trace'; import { ITableSpan } from './types'; @@ -24,11 +23,11 @@ const serviceName = 'Service Name'; const operationName = 'Operation Name'; /** - * Used to get the values if no tag is picked from the first dropdown. + * Used to get the values if tag is picked from the first dropdown. */ function getValueTagIsPicked(tableValue: ITableSpan[], trace: Trace, nameSelectorTitle: string) { const allSpans = trace.spans; - let availableTags = []; + let spansWithFilterTag = []; // add all Spans with this tag key @@ -37,44 +36,44 @@ function getValueTagIsPicked(tableValue: ITableSpan[], trace: Trace, nameSelecto for (let j = 0; j < allSpans.length; j++) { for (let l = 0; l < allSpans[j].tags.length; l++) { if (nameSelectorTitle === allSpans[j].tags[l].key) { - availableTags.push(allSpans[j]); + spansWithFilterTag.push(allSpans[j]); } } } } } - availableTags = [...new Set(availableTags)]; + spansWithFilterTag = [...new Set(spansWithFilterTag)]; - const tags = _map(availableTags, 'tags'); - let spansWithFilterTag = _uniq(_map(_flatten(tags), 'key')); - spansWithFilterTag = _filter(spansWithFilterTag, o => o !== nameSelectorTitle); - availableTags = []; - availableTags.push(serviceName); - availableTags.push(operationName); - availableTags = availableTags.concat(spansWithFilterTag); + const tags = spansWithFilterTag.map(o => o.tags); + let tagKeys = _uniq(_map(_flatten(tags), 'key')); + tagKeys = tagKeys.filter(o => o !== nameSelectorTitle); + spansWithFilterTag = []; + spansWithFilterTag.push(serviceName); + spansWithFilterTag.push(operationName); + spansWithFilterTag = spansWithFilterTag.concat(tagKeys); - return availableTags; + return spansWithFilterTag; } /** * Used to get the values if no tag is picked from the first dropdown. */ function getValueNoTagIsPicked(trace: Trace, nameSelectorTitle: string) { - let availableTags = []; + let spansWithFilterTag = []; const allSpans = trace.spans; if (nameSelectorTitle === serviceName) { - availableTags.push(operationName); + spansWithFilterTag.push(operationName); } else { - availableTags.push(serviceName); + spansWithFilterTag.push(serviceName); } for (let i = 0; i < allSpans.length; i++) { for (let j = 0; j < allSpans[i].tags.length; j++) { - availableTags.push(allSpans[i].tags[j].key); + spansWithFilterTag.push(allSpans[i].tags[j].key); } } - availableTags = [...new Set(availableTags)]; + spansWithFilterTag = [...new Set(spansWithFilterTag)]; - return availableTags; + return spansWithFilterTag; } export function generateDropdownValue(trace: Trace) { diff --git a/packages/jaeger-ui/src/components/TracePage/TraceStatistics/tableValues.tsx b/packages/jaeger-ui/src/components/TracePage/TraceStatistics/tableValues.tsx index 2d5c5fd1ed..854f57e720 100644 --- a/packages/jaeger-ui/src/components/TracePage/TraceStatistics/tableValues.tsx +++ b/packages/jaeger-ui/src/components/TracePage/TraceStatistics/tableValues.tsx @@ -13,8 +13,7 @@ // limitations under the License. import memoizeOne from 'memoize-one'; -import _uniqBy from 'lodash/uniqBy'; -import _map from 'lodash/map'; +import _uniq from 'lodash/uniq'; import DRange from 'drange'; import { Trace, Span } from '../../../types/trace'; import { ITableSpan } from './types'; @@ -116,21 +115,9 @@ function valueFirstDropdown(selectedTagKey: string, trace: Trace) { const allSpans = trace.spans; // all possibilities that can be displayed if (selectedTagKey === serviceName) { - const temp = _map( - _uniqBy(allSpans, x => x.process.serviceName), - x => ({ key: x.process.serviceName }) - ); - for (let i = 0; i < temp.length; i++) { - allDiffColumnValues.push(temp[i].key); - } + allDiffColumnValues = _uniq(allSpans.map(x => x.process.serviceName)); } else if (selectedTagKey === operationName) { - const temp = _map( - _uniqBy(allSpans, x => x.operationName), - x => ({ key: x.operationName }) - ); - for (let i = 0; i < temp.length; i++) { - allDiffColumnValues.push(temp[i].key); - } + allDiffColumnValues = _uniq(allSpans.map(x => x.operationName)); } else { for (let i = 0; i < allSpans.length; i++) { for (let j = 0; j < allSpans[i].tags.length; j++) { From 8cc2692e3d00d73ec1fee91e3df71b73f7ed8f8d Mon Sep 17 00:00:00 2001 From: Ansh Goyal Date: Tue, 12 Dec 2023 07:49:38 +0530 Subject: [PATCH 5/5] use built-in map, remove concat, revert var name change Signed-off-by: Ansh Goyal --- .../TraceStatistics/generateDropdownValue.tsx | 30 +++++++------------ .../TracePage/TraceStatistics/tableValues.tsx | 6 ++-- 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/packages/jaeger-ui/src/components/TracePage/TraceStatistics/generateDropdownValue.tsx b/packages/jaeger-ui/src/components/TracePage/TraceStatistics/generateDropdownValue.tsx index 659b1c73ee..5ce04f0169 100644 --- a/packages/jaeger-ui/src/components/TracePage/TraceStatistics/generateDropdownValue.tsx +++ b/packages/jaeger-ui/src/components/TracePage/TraceStatistics/generateDropdownValue.tsx @@ -12,10 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -import _map from 'lodash/map'; import _flatten from 'lodash/flatten'; import _uniq from 'lodash/uniq'; -import _concat from 'lodash/concat'; import { Trace } from '../../../types/trace'; import { ITableSpan } from './types'; @@ -42,45 +40,39 @@ function getValueTagIsPicked(tableValue: ITableSpan[], trace: Trace, nameSelecto } } } - spansWithFilterTag = [...new Set(spansWithFilterTag)]; + spansWithFilterTag = _uniq(spansWithFilterTag); const tags = spansWithFilterTag.map(o => o.tags); - let tagKeys = _uniq(_map(_flatten(tags), 'key')); + let tagKeys = _uniq(_flatten(tags).map(o => o.key)); tagKeys = tagKeys.filter(o => o !== nameSelectorTitle); - spansWithFilterTag = []; - spansWithFilterTag.push(serviceName); - spansWithFilterTag.push(operationName); - spansWithFilterTag = spansWithFilterTag.concat(tagKeys); - return spansWithFilterTag; + return [serviceName, operationName, ...tagKeys]; } /** * Used to get the values if no tag is picked from the first dropdown. */ function getValueNoTagIsPicked(trace: Trace, nameSelectorTitle: string) { - let spansWithFilterTag = []; + const availableTags = []; const allSpans = trace.spans; if (nameSelectorTitle === serviceName) { - spansWithFilterTag.push(operationName); + availableTags.push(operationName); } else { - spansWithFilterTag.push(serviceName); + availableTags.push(serviceName); } for (let i = 0; i < allSpans.length; i++) { for (let j = 0; j < allSpans[i].tags.length; j++) { - spansWithFilterTag.push(allSpans[i].tags[j].key); + availableTags.push(allSpans[i].tags[j].key); } } - spansWithFilterTag = [...new Set(spansWithFilterTag)]; - - return spansWithFilterTag; + return _uniq(availableTags); } export function generateDropdownValue(trace: Trace) { const allSpans = trace.spans; - const tags = _flatten(_map(allSpans, 'tags')); - const tagKeys = _uniq(_map(tags, 'key')); - const values = _concat(serviceName, operationName, tagKeys); + const tags = _flatten(allSpans.map(o => o.tags)); + const tagKeys = _uniq(tags.map(o => o.key)); + const values = [serviceName, operationName, ...tagKeys]; return values; } diff --git a/packages/jaeger-ui/src/components/TracePage/TraceStatistics/tableValues.tsx b/packages/jaeger-ui/src/components/TracePage/TraceStatistics/tableValues.tsx index 854f57e720..06f0e9a6b3 100644 --- a/packages/jaeger-ui/src/components/TracePage/TraceStatistics/tableValues.tsx +++ b/packages/jaeger-ui/src/components/TracePage/TraceStatistics/tableValues.tsx @@ -126,7 +126,7 @@ function valueFirstDropdown(selectedTagKey: string, trace: Trace) { } } } - allDiffColumnValues = [...new Set(allDiffColumnValues)]; + allDiffColumnValues = _uniq(allDiffColumnValues); } // used to build the table const allTableValues = []; @@ -436,7 +436,7 @@ function valueSecondDropdown( let newColumnValues = [] as any; // if second dropdown is no tag if (selectedTagKeySecond === serviceName || selectedTagKeySecond === operationName) { - diffNamesA = [...new Set(diffNamesA)]; + diffNamesA = _uniq(diffNamesA); newColumnValues = buildDetail( diffNamesA, tempArray, @@ -456,7 +456,7 @@ function valueSecondDropdown( } } } - diffNamesA = [...new Set(diffNamesA)]; + diffNamesA = _uniq(diffNamesA); newColumnValues = buildDetail( diffNamesA, tempArray,