mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-12 15:52:57 +00:00
refactor: update trace
This commit is contained in:
parent
ede91a2b1c
commit
b111df6150
@ -96,10 +96,8 @@ limitations under the License. -->
|
|||||||
node.children.push(data);
|
node.children.push(data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (node.children && node.children.length > 0) {
|
for (const nodeItem of node.children || []) {
|
||||||
node.children.forEach((nodeItem: Recordable) => {
|
traverseTree(nodeItem, spanId, segmentId, data);
|
||||||
traverseTree(nodeItem, spanId, segmentId, data);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function changeTree() {
|
function changeTree() {
|
||||||
@ -147,7 +145,7 @@ limitations under the License. -->
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
segmentHeaders.forEach((span: Span) => {
|
for (const span of segmentHeaders) {
|
||||||
if (span.refs.length) {
|
if (span.refs.length) {
|
||||||
let exit = null;
|
let exit = null;
|
||||||
for (const ref of span.refs) {
|
for (const ref of span.refs) {
|
||||||
@ -216,8 +214,8 @@ limitations under the License. -->
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
[...fixSpans, ...props.data].forEach((i) => {
|
for (const i of [...fixSpans, ...props.data]) {
|
||||||
i.label = i.endpointName || "no operation name";
|
i.label = i.endpointName || "no operation name";
|
||||||
i.children = [];
|
i.children = [];
|
||||||
if (segmentGroup[i.segmentId]) {
|
if (segmentGroup[i.segmentId]) {
|
||||||
@ -226,11 +224,11 @@ limitations under the License. -->
|
|||||||
segmentIdGroup.push(i.segmentId);
|
segmentIdGroup.push(i.segmentId);
|
||||||
segmentGroup[i.segmentId] = [i];
|
segmentGroup[i.segmentId] = [i];
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
fixSpansSize.value = fixSpans.length;
|
fixSpansSize.value = fixSpans.length;
|
||||||
segmentIdGroup.forEach((id: string) => {
|
for (const id of segmentIdGroup) {
|
||||||
const currentSegment = segmentGroup[id].sort((a: Span, b: Span) => b.parentSpanId - a.parentSpanId);
|
const currentSegment = segmentGroup[id].sort((a: Span, b: Span) => b.parentSpanId - a.parentSpanId);
|
||||||
currentSegment.forEach((s: Recordable) => {
|
for (const s of currentSegment) {
|
||||||
const index = currentSegment.findIndex((i: Span) => i.spanId === s.parentSpanId);
|
const index = currentSegment.findIndex((i: Span) => i.spanId === s.parentSpanId);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
if (
|
if (
|
||||||
@ -253,16 +251,16 @@ limitations under the License. -->
|
|||||||
s.children.push(...children);
|
s.children.push(...children);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
segmentGroup[id] = currentSegment[currentSegment.length - 1];
|
segmentGroup[id] = currentSegment[currentSegment.length - 1];
|
||||||
});
|
}
|
||||||
segmentIdGroup.forEach((id: string) => {
|
for (const id of segmentIdGroup) {
|
||||||
segmentGroup[id].refs.forEach((ref: Recordable) => {
|
for (const ref of segmentGroup[id].refs) {
|
||||||
if (ref.traceId === props.traceId) {
|
if (ref.traceId === props.traceId) {
|
||||||
traverseTree(segmentGroup[ref.parentSegmentId], ref.parentSpanId, ref.parentSegmentId, segmentGroup[id]);
|
traverseTree(segmentGroup[ref.parentSegmentId], ref.parentSpanId, ref.parentSegmentId, segmentGroup[id]);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
});
|
}
|
||||||
for (const i in segmentGroup) {
|
for (const i in segmentGroup) {
|
||||||
if (segmentGroup[i].refs.length) {
|
if (segmentGroup[i].refs.length) {
|
||||||
let exit = null;
|
let exit = null;
|
||||||
@ -282,22 +280,24 @@ limitations under the License. -->
|
|||||||
segmentId.value.push(segmentGroup[i]);
|
segmentId.value.push(segmentGroup[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
segmentId.value.forEach((i: Span | Recordable) => {
|
for (const i of segmentId.value) {
|
||||||
collapse(i);
|
collapse(i);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
function collapse(d: Span | Recordable) {
|
function collapse(d: Span | Recordable) {
|
||||||
if (d.children) {
|
if (d.children) {
|
||||||
const item = refSpans.value.find((s: Ref) => s.parentSpanId === d.spanId && s.parentSegmentId === d.segmentId);
|
const item = refSpans.value.find((s: Ref) => s.parentSpanId === d.spanId && s.parentSegmentId === d.segmentId);
|
||||||
let dur = d.endTime - d.startTime;
|
let dur = d.endTime - d.startTime;
|
||||||
d.children.forEach((i: Span) => {
|
for (const i of d.children) {
|
||||||
dur -= i.endTime - i.startTime;
|
dur -= i.endTime - i.startTime;
|
||||||
});
|
}
|
||||||
d.dur = dur < 0 ? 0 : dur;
|
d.dur = dur < 0 ? 0 : dur;
|
||||||
if (item) {
|
if (item) {
|
||||||
d.children = d.children.sort(compare("startTime"));
|
d.children = d.children.sort(compare("startTime"));
|
||||||
}
|
}
|
||||||
d.children.forEach((i: Span) => collapse(i));
|
for (const i of d.children) {
|
||||||
|
collapse(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function compare(p: string) {
|
function compare(p: string) {
|
||||||
|
Loading…
Reference in New Issue
Block a user