feat: update tasks query

This commit is contained in:
Fine 2023-05-23 11:19:02 +08:00
parent b8ad72e1cc
commit 2c38d9c1f8
8 changed files with 56 additions and 10 deletions

View File

@ -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

View File

@ -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,
}

View File

@ -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<Recordable<StrategyItem>>;
selectedStrategyTask: Recordable<StrategyItem>;
selectedStrategy: Recordable<StrategyItem>;
taskList: Array<Recordable<EBPFTaskList>>;
selectedContinousTask: Recordable<EBPFTaskList>;
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<StrategyItem>) {
this.selectedStrategyTask = task || {};
setSelectedStrategy(task: Recordable<StrategyItem>) {
this.selectedStrategy = task || {};
},
setSelectedContinousTask(task: Recordable<EBPFTaskList>) {
this.selectedContinousTask = task || {};
},
setNode(node: Nullable<ProcessNode>) {
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);

View File

@ -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<Recordable<EBPFTaskList>>;
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;
},

View File

@ -35,7 +35,7 @@ limitations under the License. -->
<td
class="profile-td"
:class="{
selected: continousProfilingStore.selectedStrategyTask.id === i.id,
selected: continousProfilingStore.selectedStrategy.id === i.id,
}"
>
<div class="ell">
@ -84,7 +84,7 @@ limitations under the License. -->
}
async function changePolicy(item: StrategyItem) {
continousProfilingStore.setSelectedStrategyTask(item);
continousProfilingStore.setSelectedStrategy(item);
}
function setStrategies() {

View File

@ -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) {

View File

@ -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) {