diff --git a/src/types/ebpf.d.ts b/src/types/ebpf.d.ts index 36ed2082..53badf56 100644 --- a/src/types/ebpf.d.ts +++ b/src/types/ebpf.d.ts @@ -77,6 +77,21 @@ export type StackElement = { rateOfRoot?: string; rateOfParent: string; }; +export type TraceProfilingElement = { + id: string; + originId: string; + name: string; + parentId: string; + codeSignature: string; + count: number; + stackType: string; + value: number; + children?: TraceProfilingElement[]; + rateOfRoot?: string; + rateOfParent: string; + duration: number; + durationChildExcluded: number; +}; export type AnalyzationTrees = { id: string; parentId: string; diff --git a/src/utils/flameGraph.ts b/src/utils/flameGraph.ts new file mode 100644 index 00000000..98e4d192 --- /dev/null +++ b/src/utils/flameGraph.ts @@ -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; +} diff --git a/src/views/dashboard/related/ebpf/components/EBPFStack.vue b/src/views/dashboard/related/ebpf/components/EBPFStack.vue index 988f2193..190d732d 100644 --- a/src/views/dashboard/related/ebpf/components/EBPFStack.vue +++ b/src/views/dashboard/related/ebpf/components/EBPFStack.vue @@ -28,6 +28,7 @@ limitations under the License. --> import type { StackElement } from "@/types/ebpf"; import { AggregateTypes } from "./data"; import "d3-flame-graph/dist/d3-flamegraph.css"; + import { treeForeach } from "@/utils/flameGraph"; /*global Nullable, defineProps*/ const props = defineProps({ @@ -180,14 +181,6 @@ limitations under the License. --> 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( () => ebpfStore.analyzeTrees, () => { diff --git a/src/views/dashboard/related/profile/Content.vue b/src/views/dashboard/related/profile/Content.vue index e6f3be83..2adcfc94 100644 --- a/src/views/dashboard/related/profile/Content.vue +++ b/src/views/dashboard/related/profile/Content.vue @@ -19,9 +19,11 @@ limitations under the License. -->
- +
+
diff --git a/src/views/dashboard/related/profile/components/SpanTree.vue b/src/views/dashboard/related/profile/components/SpanTree.vue index 217473e3..e69f86a6 100644 --- a/src/views/dashboard/related/profile/components/SpanTree.vue +++ b/src/views/dashboard/related/profile/components/SpanTree.vue @@ -19,12 +19,20 @@ limitations under the License. --> + {{ t("analyze") }} @@ -49,13 +57,14 @@ limitations under the License. --> import type { Span } from "@/types/trace"; import type { Option } from "@/types/app"; import { ElMessage } from "element-plus"; - import { ProfileMode } from "./data"; + import { ProfileDataMode, ProfileDisplayMode } from "./data"; /* global defineEmits*/ - const emits = defineEmits(["loading"]); + const emits = defineEmits(["loading", "displayMode"]); const { t } = useI18n(); const profileStore = useProfileStore(); - const mode = ref("include"); + const dataMode = ref("include"); + const displayMode = ref("tree"); const message = ref(""); const timeRange = ref>([]); @@ -64,10 +73,15 @@ limitations under the License. --> } function spanModeChange(item: Option[]) { - mode.value = item[0].value; + dataMode.value = item[0].value; updateTimeRange(); } + function selectDisplayMode(item: Option[]) { + displayMode.value = item[0].value; + emits("displayMode", displayMode.value); + } + async function analyzeProfile() { if (!profileStore.currentSpan.profiled) { ElMessage.info("It's a un-profiled span"); @@ -92,7 +106,7 @@ limitations under the License. --> } function updateTimeRange() { - if (mode.value === "include") { + if (dataMode.value === "include") { timeRange.value = [ { start: profileStore.currentSpan.startTime, @@ -158,7 +172,7 @@ limitations under the License. --> .profile-trace-detail-wrapper { padding: 5px 0; - border-bottom: 1px solid rgba(0, 0, 0, 0.1); + border-bottom: 1px solid rgb(0 0 0 / 10%); width: 100%; } diff --git a/src/views/dashboard/related/profile/components/data.ts b/src/views/dashboard/related/profile/components/data.ts index a382e5a9..16bd5e69 100644 --- a/src/views/dashboard/related/profile/components/data.ts +++ b/src/views/dashboard/related/profile/components/data.ts @@ -14,10 +14,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -export const ProfileMode: any[] = [ +export const ProfileDataMode: any[] = [ { label: "Include Children", value: "include" }, { label: "Exclude Children", value: "exclude" }, ]; +export const ProfileDisplayMode: any[] = [ + { label: "Tree Graph", value: "tree" }, + { label: "Flame Graph", value: "flame" }, +]; export const NewTaskField = { service: { key: "", label: "None" }, monitorTime: { key: "0", label: "monitor now" },