diff --git a/src/graphql/fragments/ebpf.ts b/src/graphql/fragments/ebpf.ts index b32333f7..c012cde9 100644 --- a/src/graphql/fragments/ebpf.ts +++ b/src/graphql/fragments/ebpf.ts @@ -33,9 +33,10 @@ export const createEBPFTask = { }`, }; export const queryEBPFTasks = { - variable: "$serviceId: ID, $serviceInstanceId: ID, $targets: [EBPFProfilingTargetType!]", + variable: + "$serviceId: ID, $serviceInstanceId: ID, $targets: [EBPFProfilingTargetType!], triggerType: EBPFProfilingTriggerType", query: ` - queryEBPFTasks: queryEBPFProfilingTasks(serviceId: $serviceId, serviceInstanceId: $serviceInstanceId, targets: $targets) { + queryEBPFTasks: queryEBPFProfilingTasks(serviceId: $serviceId, serviceInstanceId: $serviceInstanceId, targets: $targets, triggerType: $triggerType) { taskId serviceName serviceId diff --git a/src/store/data.ts b/src/store/data.ts index 94e6b432..85822711 100644 --- a/src/store/data.ts +++ b/src/store/data.ts @@ -48,3 +48,9 @@ export const ControlsTypes = [ "ThirdPartyApp", "ContinuousProfiling", ]; +export enum EBPFProfilingTriggerType { + // Appoint the task executing total duration + FIXED_TIME, + // Trigger by the reach the continuous profiling policy + CONTINUOUS_PROFILING, +} diff --git a/src/store/modules/continous-profiling.ts b/src/store/modules/continous-profiling.ts index 9179e1ac..8e447c12 100644 --- a/src/store/modules/continous-profiling.ts +++ b/src/store/modules/continous-profiling.ts @@ -16,7 +16,7 @@ */ import { defineStore } from "pinia"; import type { StrategyItem, CheckItems } from "@/types/continous-profiling"; -import type { ProcessNode } from "@/types/ebpf"; +import type { ProcessNode, EBPFTaskList } from "@/types/ebpf"; import { store } from "@/store"; import graphql from "@/graphql"; import type { AxiosResponse } from "axios"; @@ -26,7 +26,10 @@ import type { DurationTime } from "@/types/app"; interface ContinousProfilingState { strategyList: Array>; - selectedStrategyTask: Recordable; + selectedStrategy: Recordable; + taskList: Array>; + selectedContinousTask: Recordable; + errorTip: string; errorReason: string; nodes: ProcessNode[]; calls: Call[]; @@ -43,8 +46,11 @@ export const continousProfilingStore = defineStore({ id: "continousProfiling", state: (): ContinousProfilingState => ({ strategyList: [], - selectedStrategyTask: {}, + selectedStrategy: {}, + taskList: [], + selectedContinousTask: {}, errorReason: "", + errorTip: "", nodes: [], calls: [], node: null, @@ -56,8 +62,11 @@ export const continousProfilingStore = defineStore({ loadNodes: false, }), actions: { - setSelectedStrategyTask(task: Recordable) { - this.selectedStrategyTask = task || {}; + setSelectedStrategy(task: Recordable) { + this.selectedStrategy = task || {}; + }, + setSelectedContinousTask(task: Recordable) { + this.selectedContinousTask = task || {}; }, setNode(node: Nullable) { this.node = node; @@ -146,13 +155,37 @@ export const continousProfilingStore = defineStore({ id: index, }; }); - this.setSelectedStrategyTask(this.strategyList[0] || {}); + this.setSelectedStrategy(this.strategyList[0] || {}); if (!this.strategyList.length) { this.nodes = []; this.calls = []; } return res.data; }, + async getContinousTaskList(params: { + serviceId: string; + serviceInstanceId: string; + targets: string[]; + triggerType: string; + }) { + if (!params.serviceId) { + return new Promise((resolve) => resolve({})); + } + const res: AxiosResponse = await graphql.query("getEBPFTasks").params(params); + + this.errorTip = ""; + if (res.data.errors) { + return res.data; + } + this.taskList = res.data.data.queryEBPFTasks || []; + this.selectedContinousTask = this.taskList[0] || {}; + this.setSelectedContinousTask(this.selectedContinousTask); + if (!this.taskList.length) { + this.nodes = []; + this.calls = []; + } + return res.data; + }, async getProcessTopology(params: { duration: DurationTime; serviceInstanceId: string }) { this.loadNodes = true; const res: AxiosResponse = await graphql.query("getProcessTopology").params(params); diff --git a/src/store/modules/ebpf.ts b/src/store/modules/ebpf.ts index 7bc26a46..830fe453 100644 --- a/src/store/modules/ebpf.ts +++ b/src/store/modules/ebpf.ts @@ -20,6 +20,7 @@ import type { EBPFTaskCreationRequest, EBPFProfilingSchedule, EBPFTaskList, Anal import { store } from "@/store"; import graphql from "@/graphql"; import type { AxiosResponse } from "axios"; +import { EBPFProfilingTriggerType } from "../data"; interface EbpfState { taskList: Array>; eBPFSchedules: EBPFProfilingSchedule[]; @@ -77,6 +78,7 @@ export const ebpfStore = defineStore({ this.getTaskList({ serviceId: param.serviceId, targets: ["ON_CPU", "OFF_CPU"], + triggerType: EBPFProfilingTriggerType.FIXED_TIME, }); return res.data; }, diff --git a/src/views/dashboard/related/continuous-profiling/components/PolicyList.vue b/src/views/dashboard/related/continuous-profiling/components/PolicyList.vue index 7391f4e6..967aa36a 100644 --- a/src/views/dashboard/related/continuous-profiling/components/PolicyList.vue +++ b/src/views/dashboard/related/continuous-profiling/components/PolicyList.vue @@ -35,7 +35,7 @@ limitations under the License. -->
@@ -84,7 +84,7 @@ limitations under the License. --> } async function changePolicy(item: StrategyItem) { - continousProfilingStore.setSelectedStrategyTask(item); + continousProfilingStore.setSelectedStrategy(item); } function setStrategies() { diff --git a/src/views/dashboard/related/continuous-profiling/components/TaskList.vue b/src/views/dashboard/related/continuous-profiling/components/TaskList.vue new file mode 100644 index 00000000..e69de29b diff --git a/src/views/dashboard/related/ebpf/Header.vue b/src/views/dashboard/related/ebpf/Header.vue index 52dd6701..989feb7f 100644 --- a/src/views/dashboard/related/ebpf/Header.vue +++ b/src/views/dashboard/related/ebpf/Header.vue @@ -33,6 +33,7 @@ limitations under the License. --> import { useDashboardStore } from "@/store/modules/dashboard"; import { useAppStoreWithOut } from "@/store/modules/app"; import { EntityType } from "../../data"; + import { EBPFProfilingTriggerType } from "@/store/data"; /*global defineProps */ const props = defineProps({ @@ -54,6 +55,7 @@ limitations under the License. --> const res = await ebpfStore.getTaskList({ serviceId, targets: ["ON_CPU", "OFF_CPU"], + triggerType: EBPFProfilingTriggerType.FIXED_TIME, }); if (res.errors) { diff --git a/src/views/dashboard/related/network-profiling/components/Tasks.vue b/src/views/dashboard/related/network-profiling/components/Tasks.vue index 7986e101..598350cc 100644 --- a/src/views/dashboard/related/network-profiling/components/Tasks.vue +++ b/src/views/dashboard/related/network-profiling/components/Tasks.vue @@ -77,6 +77,7 @@ limitations under the License. --> import getLocalTime from "@/utils/localtime"; import { useAppStoreWithOut } from "@/store/modules/app"; import NewTask from "./NewTask.vue"; + import { EBPFProfilingTriggerType } from "@/store/data"; /*global Nullable */ const { t } = useI18n(); @@ -185,6 +186,7 @@ limitations under the License. --> serviceId, serviceInstanceId, targets: ["NETWORK"], + triggerType: EBPFProfilingTriggerType.FIXED_TIME, }); if (res.errors) {