diff --git a/src/graphql/fragments/profile.ts b/src/graphql/fragments/profile.ts index 0e6fdca8..b53ad4ff 100644 --- a/src/graphql/fragments/profile.ts +++ b/src/graphql/fragments/profile.ts @@ -149,3 +149,38 @@ export const EditStrategy = { } `, }; + +export const GetAsyncTaskList = { + variable: "$request: AsyncProfilerTaskListRequest!", + query: ` + asyncTaskList: queryAsyncProfilerTaskList(request: $request) { + errorReason + tasks { + id + serviceId + serviceInstanceIds + createTime + events + duration + execArgs + } + } + `, +}; + +export const GetAsyncProfileTaskProcess = { + variable: "$taskID: String", + query: ` + taskLogs: queryAsyncProfilerTaskProgress(taskID: $taskID) { + logs { + id + instanceId + instanceName + operationType + operationTime + } + errorInstanceIds + successInstanceIds + } + `, +}; diff --git a/src/graphql/query/profile.ts b/src/graphql/query/profile.ts index 044ffe0f..273636a0 100644 --- a/src/graphql/query/profile.ts +++ b/src/graphql/query/profile.ts @@ -23,6 +23,8 @@ import { GetProfileTaskLogs, GetStrategyList, EditStrategy, + GetAsyncTaskList, + GetAsyncProfileTaskProcess, } from "../fragments/profile"; export const saveProfileTask = `mutation createProfileTask(${CreateProfileTask.variable}) {${CreateProfileTask.query}}`; @@ -40,3 +42,7 @@ export const getProfileTaskLogs = `query profileTaskLogs(${GetProfileTaskLogs.va export const getStrategyList = `query getStrategyList(${GetStrategyList.variable}) {${GetStrategyList.query}}`; export const editStrategy = `mutation editStrategy(${EditStrategy.variable}) {${EditStrategy.query}}`; + +export const getAsyncTaskList = `query getAsyncTaskList(${GetAsyncTaskList.variable}) {${GetAsyncTaskList.query}}`; + +export const getAsyncProfileTaskProcess = `query getAsyncProfileTaskProcess(${GetAsyncProfileTaskProcess.variable}) {${GetAsyncProfileTaskProcess.query}}`; diff --git a/src/store/modules/async-profiling.ts b/src/store/modules/async-profiling.ts new file mode 100644 index 00000000..6546cd46 --- /dev/null +++ b/src/store/modules/async-profiling.ts @@ -0,0 +1,75 @@ +/** + * 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 { defineStore } from "pinia"; +import type { Option } from "@/types/app"; +import type { AsyncProfilingTaskList } from "@/types/async-profiling"; +import { store } from "@/store"; +import graphql from "@/graphql"; +import type { AxiosResponse } from "axios"; + +interface AsyncProfilingState { + taskList: Array>; + labels: Option[]; + asyncProfilingTips: string; + selectedTask: Recordable; +} + +export const asyncProfilingStore = defineStore({ + id: "asyncProfiling", + state: (): AsyncProfilingState => ({ + taskList: [], + labels: [{ value: "", label: "" }], + asyncProfilingTips: "", + selectedTask: {}, + }), + actions: { + setSelectedTask(task: Recordable) { + this.selectedTask = task || {}; + }, + async getTaskList(params: { serviceId: string; targets: string[] }) { + if (!params.serviceId) { + return new Promise((resolve) => resolve({})); + } + const res: AxiosResponse = await graphql.query("getAsyncTaskList").params(params); + + this.asyncProfilingTips = ""; + if (res.data.errors) { + return res.data; + } + this.taskList = res.data.data.asyncTaskList || []; + this.selectedTask = this.taskList[0] || {}; + this.setSelectedTask(this.selectedTask); + if (!this.taskList.length) { + return res.data; + } + return res.data; + }, + async getTaskLogs(param: { taskID: string }) { + const res: AxiosResponse = await graphql.query("getAsyncProfileTaskProcess").params(param); + + if (res.data.errors) { + return res.data; + } + this.taskLogs = res.data.data.taskLogs; + return res.data; + }, + }, +}); + +export function useAsyncProfilingStore(): Recordable { + return asyncProfilingStore(store); +} diff --git a/src/types/async-profiling.ts b/src/types/async-profiling.ts new file mode 100644 index 00000000..86e6b302 --- /dev/null +++ b/src/types/async-profiling.ts @@ -0,0 +1,26 @@ +/** + * 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 type AsyncProfilingTaskList = { + id: string; + serviceId: string; + serviceInstanceIds: string[]; + createTime: number; + events: string; + duration: number; + execArgs: string; +}; diff --git a/src/views/dashboard/related/async-profiling/components/TaskList.vue b/src/views/dashboard/related/async-profiling/components/TaskList.vue new file mode 100644 index 00000000..d411b1e1 --- /dev/null +++ b/src/views/dashboard/related/async-profiling/components/TaskList.vue @@ -0,0 +1,177 @@ + + + +