This commit is contained in:
Fine 2024-11-27 11:00:39 +08:00
parent 0eafac510f
commit ba2b457768
6 changed files with 30 additions and 11 deletions

View File

@ -15,7 +15,6 @@
* limitations under the License. * limitations under the License.
*/ */
import { defineStore } from "pinia"; import { defineStore } from "pinia";
import type { Option } from "@/types/app";
import type { import type {
AsyncProfilingTask, AsyncProfilingTask,
AsyncProfileTaskCreationRequest, AsyncProfileTaskCreationRequest,

View File

@ -54,3 +54,15 @@ type AsyncProfilerTaskLog = {
operationType: string; operationType: string;
operationTime: number; operationTime: number;
}; };
export type StackElement = {
id: string;
originId: string;
name: string;
parentId: string;
codeSignature: string;
total: number;
self: number;
value: number;
children?: StackElement[];
};

View File

@ -43,6 +43,7 @@ export interface TaskListItem {
logs: TaskLog[]; logs: TaskLog[];
errorInstanceIds: string[]; errorInstanceIds: string[];
successInstanceIds: string[]; successInstanceIds: string[];
serviceInstanceIds: string[];
} }
export interface SegmentSpan { export interface SegmentSpan {
spanId: string; spanId: string;

View File

@ -15,7 +15,7 @@ limitations under the License. -->
<template> <template>
<div class="flex-h header"> <div class="flex-h header">
<div class="title">Async Profiling</div> <div class="title">Async Profiling</div>
<el-button class="mr-20" size="small" @click="() => (newTask = true)"> <el-button class="mr-20" size="small" type="primary" @click="() => (newTask = true)">
{{ t("newTask") }} {{ t("newTask") }}
</el-button> </el-button>
</div> </div>

View File

@ -89,9 +89,9 @@ limitations under the License. -->
ElMessage.error(res.errors); ElMessage.error(res.errors);
return; return;
} }
const { tip } = res.data; const { errorReason } = res.data;
if (tip) { if (errorReason) {
ElMessage.error(tip); ElMessage.error(errorReason);
return; return;
} }
emits("close"); emits("close");

View File

@ -27,12 +27,12 @@ limitations under the License. -->
@click="changeTask(i)" @click="changeTask(i)"
:key="index" :key="index"
:class="{ :class="{
selected: asyncProfilingStore.selectedTask && asyncProfilingStore.selectedTask.id === i.id, selected: asyncProfilingStore.selectedTask.id === i.id,
}" }"
> >
<td class="profile-td"> <td class="profile-td">
<div class="ell"> <div class="ell">
<span>{{ i.endpointName }}</span> <span>{{ i.id }}</span>
<a class="profile-btn r" @click="viewTaskDetail($event, i)"> <a class="profile-btn r" @click="viewTaskDetail($event, i)">
<Icon iconName="view" size="middle" /> <Icon iconName="view" size="middle" />
</a> </a>
@ -52,7 +52,7 @@ limitations under the License. -->
</div> </div>
</div> </div>
<el-dialog v-model="showDetail" :destroy-on-close="true" fullscreen @closed="showDetail = false"> <el-dialog v-model="showDetail" :destroy-on-close="true" fullscreen @closed="showDetail = false">
<div class="profile-detail flex-v" v-if="asyncProfilingStore.selectedTask"> <div class="profile-detail flex-v" v-if="asyncProfilingStore.selectedTask.id">
<div> <div>
<h5 class="mb-10">{{ t("task") }}.</h5> <h5 class="mb-10">{{ t("task") }}.</h5>
<div class="mb-10 clear item"> <div class="mb-10 clear item">
@ -65,7 +65,7 @@ limitations under the License. -->
</div> </div>
<div class="mb-10 clear item"> <div class="mb-10 clear item">
<span class="g-sm-4 grey">{{ t("instances") }}:</span> <span class="g-sm-4 grey">{{ t("instances") }}:</span>
<span class="g-sm-8 wba">{{ asyncProfilingStore.selectedTask.serviceInstanceIds.join(", ") }}</span> <span class="g-sm-8 wba">{{ instances.map((d) => d.label).join(", ") }}</span>
</div> </div>
<div class="mb-10 clear item"> <div class="mb-10 clear item">
<span class="g-sm-4 grey">{{ t("execArgs") }}:</span> <span class="g-sm-4 grey">{{ t("execArgs") }}:</span>
@ -137,13 +137,14 @@ limitations under the License. -->
import type { TaskLog, TaskListItem } from "@/types/profile"; import type { TaskLog, TaskListItem } from "@/types/profile";
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
import { dateFormat } from "@/utils/dateFormat"; import { dateFormat } from "@/utils/dateFormat";
import type { Instance } from "@/types/selector"; import type { Instance, Service } from "@/types/selector";
const { t } = useI18n(); const { t } = useI18n();
const asyncProfilingStore = useAsyncProfilingStore(); const asyncProfilingStore = useAsyncProfilingStore();
const selectorStore = useSelectorStore(); const selectorStore = useSelectorStore();
const showDetail = ref<boolean>(false); const showDetail = ref<boolean>(false);
const service = ref<string>(""); const service = ref<string>("");
const instances = ref<Instance[]>([]);
const instanceLogs = ref<TaskLog | any>({}); const instanceLogs = ref<TaskLog | any>({});
const errorInstances = ref<Instance[]>([]); const errorInstances = ref<Instance[]>([]);
const successInstances = ref<Instance[]>([]); const successInstances = ref<Instance[]>([]);
@ -155,6 +156,9 @@ limitations under the License. -->
async function fetchTasks() { async function fetchTasks() {
const res = await asyncProfilingStore.getTaskList(); const res = await asyncProfilingStore.getTaskList();
if (res.errors) { if (res.errors) {
return ElMessage.error(res.errors);
}
if (res.data.errorReason) {
ElMessage.error(res.errors); ElMessage.error(res.errors);
} }
} }
@ -167,7 +171,10 @@ limitations under the License. -->
e.stopPropagation(); e.stopPropagation();
showDetail.value = true; showDetail.value = true;
asyncProfilingStore.setSelectedTask(item); asyncProfilingStore.setSelectedTask(item);
service.value = (selectorStore.services.filter((s: any) => s.id === item.serviceId)[0] || {}).label; service.value = (selectorStore.services.filter((s: Service) => s.id === item.serviceId)[0] || {}).label;
instances.value = asyncProfilingStore.instances.filter((d: Instance) =>
item.serviceInstanceIds.includes(d.id || ""),
);
const res = await asyncProfilingStore.getTaskLogs({ taskId: item.id }); const res = await asyncProfilingStore.getTaskLogs({ taskId: item.id });
if (res.errors) { if (res.errors) {