Tracing: Fix incorrect indentations due to reoccurring spanIDs (#41919)
* Create unique keys for trace rows * Add tests * Fix tests * Update public/app/features/explore/TraceView/TraceView.test.tsx * Trigger Build
This commit is contained in:
+13
-13
@@ -65,7 +65,7 @@ describe('<VirtualizedTraceViewImpl>', () => {
|
||||
const spans = [
|
||||
trace.spans[0],
|
||||
// this span is condidered to have collapsed children
|
||||
{ spanID: newSpanID, depth: 1 },
|
||||
{ spanID: newSpanID, depth: 1, traceID: trace.traceID },
|
||||
// these two "spans" are children and should be hidden
|
||||
{ depth: 2 },
|
||||
{ depth: 3 },
|
||||
@@ -227,20 +227,20 @@ describe('<VirtualizedTraceViewImpl>', () => {
|
||||
}
|
||||
|
||||
it('works when nothing is expanded or collapsed', () => {
|
||||
verify(0, `${trace.spans[0].spanID}--bar`);
|
||||
verify(0, `${trace.spans[0].traceID}--${trace.spans[0].spanID}--bar`);
|
||||
});
|
||||
|
||||
it('works when rows are expanded', () => {
|
||||
expandRow(1);
|
||||
verify(1, `${trace.spans[1].spanID}--bar`);
|
||||
verify(2, `${trace.spans[1].spanID}--detail`);
|
||||
verify(3, `${trace.spans[2].spanID}--bar`);
|
||||
verify(1, `${trace.spans[1].traceID}--${trace.spans[1].spanID}--bar`);
|
||||
verify(2, `${trace.spans[1].traceID}--${trace.spans[1].spanID}--detail`);
|
||||
verify(3, `${trace.spans[2].traceID}--${trace.spans[2].spanID}--bar`);
|
||||
});
|
||||
|
||||
it('works when a parent span is collapsed', () => {
|
||||
const spans = addSpansAndCollapseTheirParent();
|
||||
verify(1, `${spans[1].spanID}--bar`);
|
||||
verify(2, `${spans[4].spanID}--bar`);
|
||||
verify(1, `${spans[1].traceID}--${spans[1].spanID}--bar`);
|
||||
verify(2, `${spans[4].traceID}--${spans[4].spanID}--bar`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -250,20 +250,20 @@ describe('<VirtualizedTraceViewImpl>', () => {
|
||||
}
|
||||
|
||||
it('works when nothing is expanded or collapsed', () => {
|
||||
verify(`${trace.spans[0].spanID}--bar`, 0);
|
||||
verify(`${trace.traceID}--${trace.spans[0].spanID}--bar`, 0);
|
||||
});
|
||||
|
||||
it('works when rows are expanded', () => {
|
||||
expandRow(1);
|
||||
verify(`${trace.spans[1].spanID}--bar`, 1);
|
||||
verify(`${trace.spans[1].spanID}--detail`, 2);
|
||||
verify(`${trace.spans[2].spanID}--bar`, 3);
|
||||
verify(`${trace.spans[1].traceID}--${trace.spans[1].spanID}--bar`, 1);
|
||||
verify(`${trace.spans[1].traceID}--${trace.spans[1].spanID}--detail`, 2);
|
||||
verify(`${trace.spans[2].traceID}--${trace.spans[2].spanID}--bar`, 3);
|
||||
});
|
||||
|
||||
it('works when a parent span is collapsed', () => {
|
||||
const spans = addSpansAndCollapseTheirParent();
|
||||
verify(`${spans[1].spanID}--bar`, 1);
|
||||
verify(`${spans[4].spanID}--bar`, 2);
|
||||
verify(`${spans[1].traceID}--${spans[1].spanID}--bar`, 1);
|
||||
verify(`${spans[4].traceID}--${spans[4].spanID}--bar`, 2);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -286,17 +286,18 @@ export class UnthemedVirtualizedTraceView extends React.Component<VirtualizedTra
|
||||
// https://github.com/facebook/flow/issues/3076#issuecomment-290944051
|
||||
getKeyFromIndex = (index: number) => {
|
||||
const { isDetail, span } = this.getRowStates()[index];
|
||||
return `${span.spanID}--${isDetail ? 'detail' : 'bar'}`;
|
||||
return `${span.traceID}--${span.spanID}--${isDetail ? 'detail' : 'bar'}`;
|
||||
};
|
||||
|
||||
getIndexFromKey = (key: string) => {
|
||||
const parts = key.split('--');
|
||||
const _spanID = parts[0];
|
||||
const _isDetail = parts[1] === 'detail';
|
||||
const _traceID = parts[0];
|
||||
const _spanID = parts[1];
|
||||
const _isDetail = parts[2] === 'detail';
|
||||
const max = this.getRowStates().length;
|
||||
for (let i = 0; i < max; i++) {
|
||||
const { span, isDetail } = this.getRowStates()[i];
|
||||
if (span.spanID === _spanID && isDetail === _isDetail) {
|
||||
if (span.spanID === _spanID && span.traceID === _traceID && isDetail === _isDetail) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user