fix: display errors and ready to CR

This commit is contained in:
zhouzixin 2024-08-04 00:04:22 +08:00
parent a37332e7d0
commit 138fa1f38d
6 changed files with 41 additions and 29 deletions

2
src/types/ebpf.d.ts vendored
View File

@ -89,6 +89,8 @@ export type TraceProfilingElement = {
children?: TraceProfilingElement[]; children?: TraceProfilingElement[];
rateOfRoot?: string; rateOfRoot?: string;
rateOfParent: string; rateOfParent: string;
duration: number;
durationChildExcluded: number;
}; };
export type AnalyzationTrees = { export type AnalyzationTrees = {
id: string; id: string;

24
src/utils/flameGraph.ts Normal file
View File

@ -0,0 +1,24 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export function treeForeach(tree: any, func: (node: any) => void) {
for (const data of tree) {
data.children && treeForeach(data.children, func);
func(data);
}
return tree;
}

View File

@ -28,6 +28,7 @@ limitations under the License. -->
import type { StackElement } from "@/types/ebpf"; import type { StackElement } from "@/types/ebpf";
import { AggregateTypes } from "./data"; import { AggregateTypes } from "./data";
import "d3-flame-graph/dist/d3-flamegraph.css"; import "d3-flame-graph/dist/d3-flamegraph.css";
import { treeForeach } from "@/utils/flameGraph";
/*global Nullable, defineProps*/ /*global Nullable, defineProps*/
const props = defineProps({ const props = defineProps({
@ -180,14 +181,6 @@ limitations under the License. -->
return res; return res;
} }
function treeForeach(tree: StackElement[], func: (node: StackElement) => void) {
for (const data of tree) {
data.children && treeForeach(data.children, func);
func(data);
}
return tree;
}
watch( watch(
() => ebpfStore.analyzeTrees, () => ebpfStore.analyzeTrees,
() => { () => {

View File

@ -21,7 +21,7 @@ limitations under the License. -->
<div class="item"> <div class="item">
<SpanTree @loading="loadTrees" @displayMode="setDisplayMode" /> <SpanTree @loading="loadTrees" @displayMode="setDisplayMode" />
<div class="thread-stack"> <div class="thread-stack">
<div id="graph-stack" ref="graph" /> <div id="graph-stack" ref="graph" v-show="displayMode == 'flame'" />
<StackTable <StackTable
v-show="displayMode == 'tree'" v-show="displayMode == 'tree'"
v-if="profileStore.analyzeTrees.length" v-if="profileStore.analyzeTrees.length"
@ -47,7 +47,7 @@ limitations under the License. -->
import { flamegraph } from "d3-flame-graph"; import { flamegraph } from "d3-flame-graph";
import * as d3 from "d3"; import * as d3 from "d3";
import d3tip from "d3-tip"; import d3tip from "d3-tip";
import { AggregateTypes } from "@/views/dashboard/related/ebpf/components/data"; import { treeForeach } from "@/utils/flameGraph";
const stackTree = ref<Nullable<TraceProfilingElement>>(null); const stackTree = ref<Nullable<TraceProfilingElement>>(null);
const selectStack = ref<Nullable<TraceProfilingElement>>(null); const selectStack = ref<Nullable<TraceProfilingElement>>(null);
const graph = ref<Nullable<HTMLDivElement>>(null); const graph = ref<Nullable<HTMLDivElement>>(null);
@ -84,6 +84,8 @@ limitations under the License. -->
stackType: "", stackType: "",
rateOfRoot: "", rateOfRoot: "",
rateOfParent: "", rateOfParent: "",
duration: 0,
durationChildExcluded: 0,
}; };
countRange(); countRange();
for (const tree of profileStore.analyzeTrees) { for (const tree of profileStore.analyzeTrees) {
@ -122,10 +124,9 @@ limitations under the License. -->
.direction("s") .direction("s")
.html((d: { data: TraceProfilingElement } & { parent: { data: TraceProfilingElement } }) => { .html((d: { data: TraceProfilingElement } & { parent: { data: TraceProfilingElement } }) => {
const name = d.data.name.replace("<", "&lt;").replace(">", "&gt;"); const name = d.data.name.replace("<", "&lt;").replace(">", "&gt;");
const valStr = const dumpCount = `<div class="mb-5">Dump Count: ${d.data.count}</div>`;
profileStore.aggregateType === AggregateTypes[0].value const duration = `<div class="mb-5">Duration: ${d.data.duration} ns</div>`;
? `<div class="mb-5">Dump Count: ${d.data.count}</div>` const durationChildExcluded = `<div class="mb-5">DurationChildExcluded: ${d.data.durationChildExcluded} ns</div>`;
: `<div class="mb-5">Duration: ${d.data.count} ns</div>`;
const rateOfParent = const rateOfParent =
(d.parent && (d.parent &&
`<div class="mb-5">Percentage Of Selected: ${ `<div class="mb-5">Percentage Of Selected: ${
@ -135,7 +136,7 @@ limitations under the License. -->
const rateOfRoot = `<div class="mb-5">Percentage Of Root: ${ const rateOfRoot = `<div class="mb-5">Percentage Of Root: ${
((d.data.count / root.count) * 100).toFixed(3) + "%" ((d.data.count / root.count) * 100).toFixed(3) + "%"
}</div>`; }</div>`;
return `<div class="mb-5 name">CodeSignature: ${name}</div>${valStr}${rateOfParent}${rateOfRoot}`; return `<div class="mb-5 name">CodeSignature: ${name}</div>${dumpCount}${duration}${durationChildExcluded}${rateOfParent}${rateOfRoot}`;
}) })
.style("max-width", "400px"); .style("max-width", "400px");
flameChart.value.tooltip(tip); flameChart.value.tooltip(tip);
@ -198,14 +199,6 @@ limitations under the License. -->
return res; return res;
} }
function treeForeach(tree: TraceProfilingElement[], func: (node: TraceProfilingElement) => void) {
for (const data of tree) {
data.children && treeForeach(data.children, func);
func(data);
}
return tree;
}
watch( watch(
() => profileStore.analyzeTrees, () => profileStore.analyzeTrees,
() => { () => {

View File

@ -21,7 +21,7 @@ limitations under the License. -->
size="small" size="small"
:value="dataMode" :value="dataMode"
:options="ProfileDataMode" :options="ProfileDataMode"
placeholder="Select whether the data contains Children" placeholder="Please select a profile data mode"
@change="spanModeChange" @change="spanModeChange"
class="mr-10" class="mr-10"
/> />
@ -29,7 +29,7 @@ limitations under the License. -->
size="small" size="small"
:value="displayMode" :value="displayMode"
:options="ProfileDisplayMode" :options="ProfileDisplayMode"
placeholder="Select how to display the profiling data" placeholder="Please select a profile display mode"
@change="selectDisplayMode" @change="selectDisplayMode"
class="mr-10" class="mr-10"
/> />

View File

@ -14,14 +14,14 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
export const ProfileDataMode: any[] = [ export const ProfileDataMode = [
{ label: "Include Children", value: "include" }, { label: "Include Children", value: "include" },
{ label: "Exclude Children", value: "exclude" }, { label: "Exclude Children", value: "exclude" },
]; ] as const;
export const ProfileDisplayMode: any[] = [ export const ProfileDisplayMode = [
{ label: "Tree Graph", value: "tree" }, { label: "Tree Graph", value: "tree" },
{ label: "Flame Graph", value: "flame" }, { label: "Flame Graph", value: "flame" },
]; ] as const;
export const NewTaskField = { export const NewTaskField = {
service: { key: "", label: "None" }, service: { key: "", label: "None" },
monitorTime: { key: "0", label: "monitor now" }, monitorTime: { key: "0", label: "monitor now" },