From 488f4044be65bd2c32e6b7bc49452afcc6acc692 Mon Sep 17 00:00:00 2001 From: Qiuxia Fan Date: Tue, 19 Apr 2022 13:14:51 +0800 Subject: [PATCH] get schedules --- src/graphql/fragments/ebpf.ts | 44 ++++++++ src/graphql/query/ebpf.ts | 6 + src/store/modules/ebpf.ts | 103 ++++++------------ src/types/ebpf.d.ts | 8 ++ src/views/dashboard/related/ebpf/Content.vue | 6 + .../related/ebpf/components/EBPFSchedules.vue | 17 +++ .../related/ebpf/components/EBPFTree.vue | 17 +++ .../related/ebpf/components/TaskList.vue | 19 ++-- 8 files changed, 140 insertions(+), 80 deletions(-) create mode 100644 src/views/dashboard/related/ebpf/components/EBPFSchedules.vue create mode 100644 src/views/dashboard/related/ebpf/components/EBPFTree.vue diff --git a/src/graphql/fragments/ebpf.ts b/src/graphql/fragments/ebpf.ts index 2f4ce803..662cfb31 100644 --- a/src/graphql/fragments/ebpf.ts +++ b/src/graphql/fragments/ebpf.ts @@ -47,3 +47,47 @@ export const queryEBPFTasks = { createTime }`, }; +export const queryEBPFSchedules = { + variable: "$taskId: ID!, $duration: Duration!", + query: ` + eBPFSchedules: queryEBPFProfilingSchedules(taskId: $taskId, duration: $duration) { + scheduleId + taskId + process { + id + name + serviceId + serviceName + instanceId + instanceName + layer + agentId + detectType + attributes { + name + value + } + labels + } + startTime + endTime + }`, +}; + +export const analysisEBPFResult = { + variable: + "$scheduleIdList: [ID!]!, $timeRanges: [EBPFProfilingAnalyzeTimeRange!]!", + query: ` + analysisEBPFResult: analysisEBPFProfilingResult(scheduleIdList: $scheduleIdList, timeRanges: $timeRanges) { + tip + trees { + elements { + id + parentId + symbol + stackType + dumpCount + } + } + }`, +}; diff --git a/src/graphql/query/ebpf.ts b/src/graphql/query/ebpf.ts index 81c724b7..131b57a3 100644 --- a/src/graphql/query/ebpf.ts +++ b/src/graphql/query/ebpf.ts @@ -19,6 +19,8 @@ import { queryCreateTaskData, createEBPFTask, queryEBPFTasks, + queryEBPFSchedules, + analysisEBPFResult, } from "../fragments/ebpf"; export const getCreateTaskData = `query queryCreateTaskData(${queryCreateTaskData.variable}) {${queryCreateTaskData.query}}`; @@ -26,3 +28,7 @@ export const getCreateTaskData = `query queryCreateTaskData(${queryCreateTaskDat export const saveEBPFTask = `mutation createEBPFTask(${createEBPFTask.variable}) {${createEBPFTask.query}}`; export const getEBPFTasks = `query queryEBPFTasks(${queryEBPFTasks.variable}) {${queryEBPFTasks.query}}`; + +export const getEBPFSchedules = `query queryEBPFSchedules(${queryEBPFSchedules.variable}) {${queryEBPFSchedules.query}}`; + +export const getEBPFResult = `query analysisEBPFResult(${analysisEBPFResult.variable}) {${analysisEBPFResult.query}}`; diff --git a/src/store/modules/ebpf.ts b/src/store/modules/ebpf.ts index e99b802f..8100e6cb 100644 --- a/src/store/modules/ebpf.ts +++ b/src/store/modules/ebpf.ts @@ -22,7 +22,7 @@ import { ProfileAnalyzationTrees, TaskLog, } from "@/types/profile"; -import { EBPFTaskCreationRequest } from "@/types/ebpf"; +import { EBPFTaskCreationRequest, EBPFProfilingSchedule } from "@/types/ebpf"; import { Trace, Span } from "@/types/trace"; import { store } from "@/store"; import graphql from "@/graphql"; @@ -32,8 +32,8 @@ import { useAppStoreWithOut } from "@/store/modules/app"; interface EbpfStore { durationTime: Duration; taskList: TaskListItem[]; - segmentList: Trace[]; - currentSegment: Trace | Record; + eBPFSchedules: EBPFProfilingSchedule[]; + currentSchedule: EBPFProfilingSchedule | Record; segmentSpans: SegmentSpan[]; currentSpan: SegmentSpan | Record; analyzeTrees: ProfileAnalyzationTrees; @@ -48,8 +48,8 @@ export const ebpfStore = defineStore({ state: (): EbpfStore => ({ durationTime: useAppStoreWithOut().durationTime, taskList: [], - segmentList: [], - currentSegment: {}, + eBPFSchedules: [], + currentSchedule: {}, segmentSpans: [], currentSpan: {}, analyzeTrees: [], @@ -62,8 +62,8 @@ export const ebpfStore = defineStore({ setCurrentSpan(span: Span) { this.currentSpan = span; }, - setCurrentSegment(s: Trace) { - this.currentSegment = s; + setCurrentSchedule(s: Trace) { + this.currentSchedule = s; }, setHighlightTop() { this.highlightTop = !this.highlightTop; @@ -83,6 +83,17 @@ export const ebpfStore = defineStore({ }); return res.data; }, + async createTask(param: EBPFTaskCreationRequest) { + const res: AxiosResponse = await graphql + .query("saveEBPFTask") + .params({ request: param }); + + if (res.data.errors) { + return res.data; + } + this.getTaskList(param.serviceId); + return res.data; + }, async getTaskList(serviceId: string) { const res: AxiosResponse = await graphql .query("getEBPFTasks") @@ -95,61 +106,38 @@ export const ebpfStore = defineStore({ return res.data; }, - async getSegmentList(params: { taskID: string }) { + async getEBPFSchedules(params: { taskID: string; duration: Duration }) { const res: AxiosResponse = await graphql - .query("getProfileTaskSegmentList") + .query("getEBPFSchedules") .params(params); if (res.data.errors) { - this.segmentList = []; + this.eBPFSchedules = []; return res.data; } - const { segmentList } = res.data.data; + const { eBPFSchedules } = res.data.data; - this.segmentList = segmentList; - if (!segmentList.length) { - this.segmentSpans = []; + this.eBPFSchedules = eBPFSchedules; + if (!eBPFSchedules.length) { + this.eBPFSchedules = []; this.analyzeTrees = []; return res.data; } - if (segmentList[0]) { - this.currentSegment = segmentList[0]; - this.getSegmentSpans({ segmentId: segmentList[0].segmentId }); - } else { - this.currentSegment = null; - } + // if (eBPFSchedules[0]) { + // this.currentSchedule = eBPFSchedules[0]; + // this.getEBPFAnalyze({ scheduleIdList: eBPFSchedules[0].segmentId }); + // } else { + // this.currentSchedule = null; + // } return res.data; }, - async getSegmentSpans(params: { segmentId: string }) { - const res: AxiosResponse = await graphql - .query("queryProfileSegment") - .params(params); - if (res.data.errors) { - this.segmentSpans = []; - return res.data; - } - const { segment } = res.data.data; - if (!segment) { - this.segmentSpans = []; - this.analyzeTrees = []; - return res.data; - } - this.segmentSpans = segment.spans; - if (!(segment.spans && segment.spans.length)) { - this.analyzeTrees = []; - return res.data; - } - const index = segment.spans.length - 1 || 0; - this.currentSpan = segment.spans[index]; - return res.data; - }, - async getProfileAnalyze(params: { - segmentId: string; + async getEBPFAnalyze(params: { + scheduleIdList: string[]; timeRanges: Array<{ start: number; end: number }>; }) { const res: AxiosResponse = await graphql - .query("getProfileAnalyze") + .query("getEBPFResult") .params(params); if (res.data.errors) { @@ -169,29 +157,6 @@ export const ebpfStore = defineStore({ this.analyzeTrees = analyze.trees; return res.data; }, - async createTask(param: EBPFTaskCreationRequest) { - const res: AxiosResponse = await graphql - .query("saveEBPFTask") - .params({ request: param }); - - if (res.data.errors) { - return res.data; - } - console.log(res.data.data); - // this.getTaskList(); - return res.data; - }, - async getTaskLogs(param: { taskID: string }) { - const res: AxiosResponse = await graphql - .query("getProfileTaskLogs") - .params(param); - - if (res.data.errors) { - return res.data; - } - this.taskLogs = res.data.data.taskLogs; - return res.data; - }, }, }); diff --git a/src/types/ebpf.d.ts b/src/types/ebpf.d.ts index 72a5168b..82a9a04b 100644 --- a/src/types/ebpf.d.ts +++ b/src/types/ebpf.d.ts @@ -34,3 +34,11 @@ export interface EBPFTaskList { createTime: number; triggerType: string; } + +export interface EBPFProfilingSchedule { + scheduleId: string; + taskId: string; + process: string; + endTime: number; + startTime: number; +} diff --git a/src/views/dashboard/related/ebpf/Content.vue b/src/views/dashboard/related/ebpf/Content.vue index d72327cd..2b7aa79b 100644 --- a/src/views/dashboard/related/ebpf/Content.vue +++ b/src/views/dashboard/related/ebpf/Content.vue @@ -15,10 +15,16 @@ limitations under the License. -->