From e6259db9ab32ebb9762dc063534673a15462b205 Mon Sep 17 00:00:00 2001 From: Ruben Vargas Date: Wed, 26 Aug 2020 17:19:45 -0500 Subject: [PATCH 1/2] Fixes TraceTimelineViewer span details Signed-off-by: Ruben Vargas --- .../VirtualizedTraceView.test.js | 2 +- .../VirtualizedTraceView.tsx | 97 ++++++++++--------- 2 files changed, 50 insertions(+), 49 deletions(-) diff --git a/packages/jaeger-ui/src/components/TracePage/TraceTimelineViewer/VirtualizedTraceView.test.js b/packages/jaeger-ui/src/components/TracePage/TraceTimelineViewer/VirtualizedTraceView.test.js index d789c48b46..df79107432 100644 --- a/packages/jaeger-ui/src/components/TracePage/TraceTimelineViewer/VirtualizedTraceView.test.js +++ b/packages/jaeger-ui/src/components/TracePage/TraceTimelineViewer/VirtualizedTraceView.test.js @@ -305,7 +305,7 @@ describe('', () => { expect( rowWrapper.containsMatchingElement( , + detailStates: Map +): RowState[] { + return trace ? generateRowStates(trace.spans, childrenHiddenIDs, detailStates) : []; +} + function getCssClasses(currentViewRange: [number, number]) { const [zoomStart, zoomEnd] = currentViewRange; return cx({ @@ -138,28 +147,16 @@ function getCssClasses(currentViewRange: [number, number]) { }); } +const memoizedGenerateRowStates = memoizeOne(generateRowStatesFromTrace); +const memoizedViewBoundsFunc = memoizeOne(createViewedBoundsFunc); +const memoizedGetCssClasses = memoizeOne(getCssClasses); + // export from tests export class VirtualizedTraceViewImpl extends React.Component { - clippingCssClasses: string; listView: ListView | TNil; - rowStates: RowState[]; - getViewedBounds: ViewedBoundsFunctionType; - constructor(props: VirtualizedTraceViewProps) { super(props); - // keep "prop derivations" on the instance instead of calculating in - // `.render()` to avoid recalculating in every invocation of `.renderRow()` - const { currentViewRangeTime, childrenHiddenIDs, detailStates, setTrace, trace, uiFind } = props; - this.clippingCssClasses = getCssClasses(currentViewRangeTime); - const [zoomStart, zoomEnd] = currentViewRangeTime; - this.getViewedBounds = createViewedBoundsFunc({ - min: trace.startTime, - max: trace.endTime, - viewStart: zoomStart, - viewEnd: zoomEnd, - }); - this.rowStates = generateRowStates(trace.spans, childrenHiddenIDs, detailStates); - + const { setTrace, trace, uiFind } = props; setTrace(trace, uiFind); } @@ -180,14 +177,11 @@ export class VirtualizedTraceViewImpl extends React.Component) { - const { childrenHiddenIDs, detailStates, registerAccessors, trace, currentViewRangeTime } = prevProps; + const { registerAccessors, trace } = prevProps; const { shouldScrollToFirstUiFindMatch, clearShouldScrollToFirstUiFindMatch, scrollToFirstVisibleSpan, - currentViewRangeTime: nextViewRangeTime, - childrenHiddenIDs: nextHiddenIDs, - detailStates: nextDetailStates, registerAccessors: nextRegisterAccessors, setTrace, trace: nextTrace, @@ -198,21 +192,6 @@ export class VirtualizedTraceViewImpl extends React.Component { const { trace, focusUiFindMatches, location, history } = this.props; if (trace) { @@ -259,12 +260,12 @@ export class VirtualizedTraceViewImpl extends React.Component this.props.childrenHiddenIDs; - mapRowIndexToSpanIndex = (index: number) => this.rowStates[index].spanIndex; + mapRowIndexToSpanIndex = (index: number) => this.getRowStates()[index].spanIndex; mapSpanIndexToRowIndex = (index: number) => { - const max = this.rowStates.length; + const max = this.getRowStates().length; for (let i = 0; i < max; i++) { - const { spanIndex } = this.rowStates[i]; + const { spanIndex } = this.getRowStates()[i]; if (spanIndex === index) { return i; } @@ -283,7 +284,7 @@ export class VirtualizedTraceViewImpl extends React.Component { - const { isDetail, span } = this.rowStates[index]; + const { isDetail, span } = this.getRowStates()[index]; return `${span.spanID}--${isDetail ? 'detail' : 'bar'}`; }; @@ -291,9 +292,9 @@ export class VirtualizedTraceViewImpl extends React.Component { - const { span, isDetail } = this.rowStates[index]; + const { span, isDetail } = this.getRowStates()[index]; if (!isDetail) { return DEFAULT_HEIGHTS.bar; } @@ -315,7 +316,7 @@ export class VirtualizedTraceViewImpl extends React.Component getLinks(span, items, itemIndex); renderRow = (key: string, style: React.CSSProperties, index: number, attrs: {}) => { - const { isDetail, span, spanIndex } = this.rowStates[index]; + const { isDetail, span, spanIndex } = this.getRowStates()[index]; return isDetail ? this.renderSpanDetailRow(span, key, style, attrs) : this.renderSpanBarRow(span, spanIndex, key, style, attrs); @@ -348,7 +349,7 @@ export class VirtualizedTraceViewImpl extends React.Component Date: Fri, 4 Sep 2020 14:23:15 -0500 Subject: [PATCH 2/2] perform deep comparision for memoized ViewBoundsFunc and GetCssClasses Signed-off-by: Ruben Vargas --- .../TracePage/TraceTimelineViewer/VirtualizedTraceView.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/jaeger-ui/src/components/TracePage/TraceTimelineViewer/VirtualizedTraceView.tsx b/packages/jaeger-ui/src/components/TracePage/TraceTimelineViewer/VirtualizedTraceView.tsx index 9b33ff50b4..8187a8a32b 100644 --- a/packages/jaeger-ui/src/components/TracePage/TraceTimelineViewer/VirtualizedTraceView.tsx +++ b/packages/jaeger-ui/src/components/TracePage/TraceTimelineViewer/VirtualizedTraceView.tsx @@ -17,6 +17,7 @@ import cx from 'classnames'; import { connect } from 'react-redux'; import { bindActionCreators, Dispatch } from 'redux'; import { withRouter, RouteComponentProps } from 'react-router-dom'; +import _isEqual from 'lodash/isEqual'; // import { History as RouterHistory, Location } from 'history'; @@ -148,8 +149,8 @@ function getCssClasses(currentViewRange: [number, number]) { } const memoizedGenerateRowStates = memoizeOne(generateRowStatesFromTrace); -const memoizedViewBoundsFunc = memoizeOne(createViewedBoundsFunc); -const memoizedGetCssClasses = memoizeOne(getCssClasses); +const memoizedViewBoundsFunc = memoizeOne(createViewedBoundsFunc, _isEqual); +const memoizedGetCssClasses = memoizeOne(getCssClasses, _isEqual); // export from tests export class VirtualizedTraceViewImpl extends React.Component {