diff --git a/src/graphql/fragments/ebpf.ts b/src/graphql/fragments/ebpf.ts new file mode 100644 index 00000000..e9ca9da6 --- /dev/null +++ b/src/graphql/fragments/ebpf.ts @@ -0,0 +1,34 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const queryCreateTaskData = { + variable: "$serviceId: ID!", + query: ` + createTaskData: queryPrepareCreateEBPFProfilingTaskData(serviceId: $serviceId) { + couldProfiling + processLabels + }`, +}; +export const createEBPFTask = { + variable: "$request: EBPFProfilingTaskFixedTimeCreationRequest!", + query: ` + createTaskData: createEBPFProfilingFixedTimeTask(request: $request) { + status + errorReason + id + }`, +}; diff --git a/src/graphql/index.ts b/src/graphql/index.ts index ab6fd319..3b76c9fb 100644 --- a/src/graphql/index.ts +++ b/src/graphql/index.ts @@ -25,6 +25,7 @@ import * as log from "./query/log"; import * as profile from "./query/profile"; import * as alarm from "./query/alarm"; import * as event from "./query/event"; +import * as ebpf from "./query/ebpf"; const query: { [key: string]: string } = { ...app, @@ -36,6 +37,7 @@ const query: { [key: string]: string } = { ...profile, ...alarm, ...event, + ...ebpf, }; class Graphql { private queryData = ""; diff --git a/src/graphql/query/ebpf.ts b/src/graphql/query/ebpf.ts new file mode 100644 index 00000000..f8180934 --- /dev/null +++ b/src/graphql/query/ebpf.ts @@ -0,0 +1,22 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { queryCreateTaskData, createEBPFTask } from "../fragments/ebpf"; + +export const getCreateTaskData = `query queryCreateTaskData(${queryCreateTaskData.variable}) {${queryCreateTaskData.query}}`; + +export const saveEBPFTask = `mutation createEBPFTask(${createEBPFTask.variable}) {${createEBPFTask.query}}`; diff --git a/src/store/modules/ebpf.ts b/src/store/modules/ebpf.ts index 75cbe19e..f1220d03 100644 --- a/src/store/modules/ebpf.ts +++ b/src/store/modules/ebpf.ts @@ -16,14 +16,13 @@ */ import { defineStore } from "pinia"; import { Duration, Option } from "@/types/app"; -import { Endpoint } from "@/types/selector"; import { TaskListItem, SegmentSpan, ProfileAnalyzationTrees, TaskLog, - ProfileTaskCreationRequest, } from "@/types/profile"; +import { EBPFTaskCreationRequest } from "@/types/ebpf"; import { Trace, Span } from "@/types/trace"; import { store } from "@/store"; import graphql from "@/graphql"; @@ -31,8 +30,6 @@ import { AxiosResponse } from "axios"; import { useAppStoreWithOut } from "@/store/modules/app"; interface EbpfStore { - endpoints: Endpoint[]; - taskEndpoints: Endpoint[]; durationTime: Duration; condition: { serviceId: string; endpointName: string }; taskList: TaskListItem[]; @@ -44,13 +41,12 @@ interface EbpfStore { taskLogs: TaskLog[]; highlightTop: boolean; labels: Option[]; + couldProfiling: boolean; } export const ebpfStore = defineStore({ - id: "profile", + id: "eBPF", state: (): EbpfStore => ({ - endpoints: [{ value: "", label: "All" }], - taskEndpoints: [{ value: "", label: "All" }], durationTime: useAppStoreWithOut().durationTime, condition: { serviceId: "", endpointName: "" }, taskList: [], @@ -62,6 +58,7 @@ export const ebpfStore = defineStore({ taskLogs: [], highlightTop: true, labels: [{ value: "", label: "" }], + couldProfiling: false, }), actions: { setConditions(data: { serviceId?: string; endpointName?: string }) { @@ -79,28 +76,19 @@ export const ebpfStore = defineStore({ setHighlightTop() { this.highlightTop = !this.highlightTop; }, - async getEndpoints(serviceId: string, keyword?: string) { - const res: AxiosResponse = await graphql.query("queryEndpoints").params({ - serviceId, - duration: this.durationTime, - keyword: keyword || "", - }); + async getCreateTaskData(serviceId: string) { + const res: AxiosResponse = await graphql + .query("getCreateTaskData") + .params({ serviceId }); + if (res.data.errors) { return res.data; } - this.endpoints = [{ value: "", label: "All" }, ...res.data.data.pods]; - return res.data; - }, - async getTaskEndpoints(serviceId: string, keyword?: string) { - const res: AxiosResponse = await graphql.query("queryEndpoints").params({ - serviceId, - duration: this.durationTime, - keyword: keyword || "", + const json = res.data.data.createTaskData; + this.couldProfiling = json.couldProfiling || []; + this.labels = json.processLabels.map((d: string) => { + return { label: d, value: d }; }); - if (res.data.errors) { - return res.data; - } - this.taskEndpoints = [{ value: "", label: "All" }, ...res.data.data.pods]; return res.data; }, async getTaskList() { @@ -197,15 +185,16 @@ export const ebpfStore = defineStore({ this.analyzeTrees = analyze.trees; return res.data; }, - async createTask(param: ProfileTaskCreationRequest) { + async createTask(param: EBPFTaskCreationRequest) { const res: AxiosResponse = await graphql - .query("saveProfileTask") - .params({ creationRequest: param }); + .query("saveEBPFTask") + .params({ request: param }); if (res.data.errors) { return res.data; } - this.getTaskList(); + console.log(res.data.data); + // this.getTaskList(); return res.data; }, async getTaskLogs(param: { taskID: string }) { diff --git a/src/types/dashboard.ts b/src/types/dashboard.d.ts similarity index 100% rename from src/types/dashboard.ts rename to src/types/dashboard.d.ts diff --git a/src/types/ebpf.d.ts b/src/types/ebpf.d.ts new file mode 100644 index 00000000..2c491f93 --- /dev/null +++ b/src/types/ebpf.d.ts @@ -0,0 +1,24 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export interface EBPFTaskCreationRequest { + serviceId: string; + processLabels: string[]; + startTime: number; + duration: number; + targetType: string; +} diff --git a/src/views/dashboard/related/ebpf/Header.vue b/src/views/dashboard/related/ebpf/Header.vue index a8af8c04..6400e3f2 100644 --- a/src/views/dashboard/related/ebpf/Header.vue +++ b/src/views/dashboard/related/ebpf/Header.vue @@ -14,27 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. -->