From a37332e7d03e8eca9720ed4721849342569b4e00 Mon Sep 17 00:00:00 2001 From: zhouzixin Date: Wed, 31 Jul 2024 08:24:20 +0800 Subject: [PATCH] feat: introduce flame graph to the trace profiling --- src/types/ebpf.d.ts | 13 ++ .../dashboard/related/profile/Content.vue | 189 +++++++++++++++++- .../related/profile/components/SpanTree.vue | 32 ++- .../related/profile/components/data.ts | 6 +- 4 files changed, 227 insertions(+), 13 deletions(-) diff --git a/src/types/ebpf.d.ts b/src/types/ebpf.d.ts index 36ed2082..ae87d923 100644 --- a/src/types/ebpf.d.ts +++ b/src/types/ebpf.d.ts @@ -77,6 +77,19 @@ 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; +}; export type AnalyzationTrees = { id: string; parentId: string; diff --git a/src/views/dashboard/related/profile/Content.vue b/src/views/dashboard/related/profile/Content.vue index e6f3be83..74c8540d 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..48ad4b8b 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" },