feat: support the process dashboard and create the time range text widget (#138)

This commit is contained in:
Fine0830
2022-08-15 16:49:00 +08:00
committed by GitHub
parent 973b51e9ca
commit 9c0bb988e6
44 changed files with 1133 additions and 213 deletions

View File

@@ -29,3 +29,11 @@ export const TextConfig = {
fontSize: 14,
textAlign: "left",
};
export const TimeRangeConfig = {
fontColor: "black",
backgroundColor: "white",
fontSize: 14,
textAlign: "center",
text: "text",
};

View File

@@ -21,7 +21,7 @@ import graphql from "@/graphql";
import query from "@/graphql/fetch";
import { DashboardItem } from "@/types/dashboard";
import { useSelectorStore } from "@/store/modules/selectors";
import { NewControl, TextConfig } from "../data";
import { NewControl, TextConfig, TimeRangeConfig } from "../data";
import { AxiosResponse } from "axios";
import { ElMessage } from "element-plus";
import { useI18n } from "vue-i18n";
@@ -113,13 +113,27 @@ export const dashboardStore = defineStore({
: 3,
};
}
if (["Trace", "Profile", "Log", "DemandLog", "Ebpf"].includes(type)) {
if (
[
"Trace",
"Profile",
"Log",
"DemandLog",
"Ebpf",
"NetworkProfiling",
].includes(type)
) {
newItem.h = 36;
}
if (type === "Text") {
newItem.h = 6;
newItem.graph = TextConfig;
}
if (type === "TimeRange") {
newItem.w = 8;
newItem.h = 6;
newItem.graph = TimeRangeConfig;
}
this.activedGridItem = newItem.i;
this.selectedGrid = newItem;
this.layout = this.layout.map((d: LayoutConfig) => {
@@ -170,13 +184,27 @@ export const dashboardStore = defineStore({
showDepth: true,
};
}
if (["Trace", "Profile", "Log", "DemandLog", "Ebpf"].includes(type)) {
if (
[
"Trace",
"Profile",
"Log",
"DemandLog",
"Ebpf",
"NetworkProfiling",
].includes(type)
) {
newItem.h = 32;
}
if (type === "Text") {
newItem.h = 6;
newItem.graph = TextConfig;
}
if (type === "TimeRange") {
newItem.w = 8;
newItem.h = 6;
newItem.graph = TextConfig;
}
if (this.layout[idx].children) {
const items = children.map((d: LayoutConfig) => {
d.y = d.y + newItem.h;

View File

@@ -25,8 +25,7 @@ import {
import { store } from "@/store";
import graphql from "@/graphql";
import { AxiosResponse } from "axios";
interface EbpfStore {
interface EbpfState {
taskList: EBPFTaskList[];
eBPFSchedules: EBPFProfilingSchedule[];
currentSchedule: EBPFProfilingSchedule | Record<string, never>;
@@ -40,7 +39,7 @@ interface EbpfStore {
export const ebpfStore = defineStore({
id: "eBPF",
state: (): EbpfStore => ({
state: (): EbpfState => ({
taskList: [],
eBPFSchedules: [],
currentSchedule: {},
@@ -53,7 +52,7 @@ export const ebpfStore = defineStore({
}),
actions: {
setSelectedTask(task: EBPFTaskList) {
this.selectedTask = task;
this.selectedTask = task || {};
},
setCurrentSchedule(s: EBPFProfilingSchedule) {
this.currentSchedule = s;
@@ -84,22 +83,31 @@ export const ebpfStore = defineStore({
if (res.data.errors) {
return res.data;
}
this.getTaskList(param.serviceId);
this.getTaskList({
serviceId: param.serviceId,
targets: ["ON_CPU", "OFF_CPU"],
});
return res.data;
},
async getTaskList(serviceId: string) {
if (!serviceId) {
async getTaskList(params: {
serviceId: string;
serviceInstanceId: string;
targets: string[];
}) {
if (!params.serviceId) {
return new Promise((resolve) => resolve({}));
}
const res: AxiosResponse = await graphql
.query("getEBPFTasks")
.params({ serviceId });
.params(params);
this.tip = "";
if (res.data.errors) {
return res.data;
}
this.taskList = res.data.data.queryEBPFTasks || [];
this.selectedTask = this.taskList[0] || {};
this.setSelectedTask(this.selectedTask);
if (!this.taskList.length) {
return res.data;
}

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { defineStore } from "pinia";
import { Service, Instance, Endpoint } from "@/types/selector";
import { Service, Instance, Endpoint, Process } from "@/types/selector";
import { store } from "@/store";
import graphql from "@/graphql";
import { AxiosResponse } from "axios";
@@ -24,11 +24,15 @@ interface SelectorState {
services: Service[];
destServices: Service[];
pods: Array<Instance | Endpoint>;
processes: Process[];
destProcesses: Process[];
currentService: Nullable<Service>;
currentPod: Nullable<Instance | Endpoint>;
currentProcess: Nullable<Process>;
currentDestService: Nullable<Service>;
currentDestPod: Nullable<Instance | Endpoint>;
destPods: Array<Instance | Endpoint>;
currentDestProcess: Nullable<Process>;
}
export const selectorStore = defineStore({
@@ -38,10 +42,14 @@ export const selectorStore = defineStore({
destServices: [],
pods: [],
destPods: [],
processes: [],
destProcesses: [],
currentService: null,
currentPod: null,
currentProcess: null,
currentDestService: null,
currentDestPod: null,
currentDestProcess: null,
}),
actions: {
setCurrentService(service: Nullable<Service>) {
@@ -56,6 +64,18 @@ export const selectorStore = defineStore({
setCurrentDestPod(pod: Nullable<Instance | Endpoint>) {
this.currentDestPod = pod;
},
setCurrentProcess(process: Nullable<Process>) {
this.currentProcess = process;
},
setCurrentDestProcess(process: Nullable<Process>) {
this.currentDestProcess = process;
},
setDestPods(pods: Array<Instance | Endpoint>) {
this.destPods = pods;
},
setDestProcesses(processes: Array<Process>) {
this.destProcesses = processes;
},
async fetchLayers(): Promise<AxiosResponse> {
const res: AxiosResponse = await graphql.query("queryLayers").params({});
@@ -93,6 +113,27 @@ export const selectorStore = defineStore({
}
return res.data;
},
async getProcesses(param?: {
instanceId: string;
isRelation: boolean;
}): Promise<Nullable<AxiosResponse>> {
const instanceId = param ? param.instanceId : this.currentPod?.id;
if (!instanceId) {
return null;
}
const res: AxiosResponse = await graphql.query("queryProcesses").params({
instanceId,
duration: useAppStoreWithOut().durationTime,
});
if (!res.data.errors) {
if (param && param.isRelation) {
this.destProcesses = res.data.data.processes || [];
return res.data;
}
this.processes = res.data.data.processes || [];
}
return res.data;
},
async getEndpoints(params: {
keyword?: string;
serviceId?: string;
@@ -176,6 +217,25 @@ export const selectorStore = defineStore({
this.pods = [res.data.data.endpoint];
}
return res.data;
},
async getProcess(instanceId: string, isRelation?: boolean) {
if (!instanceId) {
return;
}
const res: AxiosResponse = await graphql.query("queryProcess").params({
instanceId,
});
if (!res.data.errors) {
if (isRelation) {
this.currentDestProcess = res.data.data.process || null;
this.destProcesses = [res.data.data.process];
return;
}
this.currentProcess = res.data.data.process || null;
this.processes = [res.data.data.process];
}
return res.data;
},
},