mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-06 18:12:54 +00:00
refactor
This commit is contained in:
parent
464827e8a1
commit
86eee044be
@ -195,7 +195,6 @@ limitations under the License. -->
|
|||||||
const key = props.data.refs.findIndex((d: { type: string }) => d.type === "CROSS_THREAD");
|
const key = props.data.refs.findIndex((d: { type: string }) => d.type === "CROSS_THREAD");
|
||||||
return key > -1 ? true : false;
|
return key > -1 ? true : false;
|
||||||
});
|
});
|
||||||
|
|
||||||
function toggle() {
|
function toggle() {
|
||||||
displayChildren.value = !displayChildren.value;
|
displayChildren.value = !displayChildren.value;
|
||||||
}
|
}
|
||||||
|
@ -15,42 +15,13 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { Ref, Span, TraceTreeRef } from "@/types/trace";
|
import type { Span, TraceTreeRef } from "@/types/trace";
|
||||||
|
|
||||||
export default class TraceUtil {
|
export default class TraceUtil {
|
||||||
public static buildTraceDataList(data: Span[]): string[] {
|
public static buildTraceDataList(data: Span[]): string[] {
|
||||||
return Array.from(new Set(data.map((span: Span) => span.serviceCode)));
|
return Array.from(new Set(data.map((span: Span) => span.serviceCode)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static changeTree(data: Span[], currentTraceId: string) {
|
|
||||||
const segmentIdList: Span[] = [];
|
|
||||||
const traceTreeRef: Recordable = this.changeTreeCore(data);
|
|
||||||
traceTreeRef.segmentIdGroup.forEach((segmentId: string) => {
|
|
||||||
if (traceTreeRef.segmentMap.get(segmentId).refs) {
|
|
||||||
traceTreeRef.segmentMap.get(segmentId).refs.forEach((ref: Ref) => {
|
|
||||||
if (ref.traceId === currentTraceId) {
|
|
||||||
this.traverseTree(
|
|
||||||
traceTreeRef.segmentMap.get(ref.parentSegmentId) as Span,
|
|
||||||
ref.parentSpanId,
|
|
||||||
ref.parentSegmentId,
|
|
||||||
traceTreeRef.segmentMap.get(segmentId) as Span,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// set a breakpoint at this line
|
|
||||||
traceTreeRef.segmentMap.forEach((value: Span) => {
|
|
||||||
if ((value.refs && value.refs.length === 0) || !value.refs) {
|
|
||||||
segmentIdList.push(value as Span);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
segmentIdList.forEach((segmentId: Span) => {
|
|
||||||
this.collapse(segmentId);
|
|
||||||
});
|
|
||||||
return segmentIdList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static changeStatisticsTree(data: Span[]): Map<string, Span[]> {
|
public static changeStatisticsTree(data: Span[]): Map<string, Span[]> {
|
||||||
const result = new Map<string, Span[]>();
|
const result = new Map<string, Span[]>();
|
||||||
const traceTreeRef = this.changeTreeCore(data);
|
const traceTreeRef = this.changeTreeCore(data);
|
||||||
@ -255,21 +226,6 @@ export default class TraceUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static traverseTree(node: Span, spanId: number, segmentId: string, childNode: Span) {
|
|
||||||
if (!node || node.isBroken) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (node.spanId === spanId && node.segmentId === segmentId) {
|
|
||||||
node.children!.push(childNode);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (node.children && node.children.length > 0) {
|
|
||||||
for (const grandchild of node.children) {
|
|
||||||
this.traverseTree(grandchild, spanId, segmentId, childNode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static calculationChildren(nodes: Span[], result: Map<string, Span[]>): void {
|
private static calculationChildren(nodes: Span[], result: Map<string, Span[]>): void {
|
||||||
nodes.forEach((node: Span) => {
|
nodes.forEach((node: Span) => {
|
||||||
const groupRef = node.endpointName + ":" + node.type;
|
const groupRef = node.endpointName + ":" + node.type;
|
||||||
|
Loading…
Reference in New Issue
Block a user