add errorInstances

This commit is contained in:
Fine 2024-11-22 14:47:33 +08:00
parent c5a82baca6
commit ae71c43a3f
5 changed files with 62 additions and 3 deletions

View File

@ -171,7 +171,7 @@ export const GetAsyncTaskList = {
export const GetAsyncProfileTaskProcess = {
variable: "$taskID: String",
query: `
taskLogs: queryAsyncProfilerTaskProgress(taskID: $taskID) {
taskProgress: queryAsyncProfilerTaskProgress(taskID: $taskID) {
logs {
id
instanceId

View File

@ -19,13 +19,17 @@ import type { Option } from "@/types/app";
import type { AsyncProfilingTaskList } from "@/types/async-profiling";
import { store } from "@/store";
import graphql from "@/graphql";
import { useAppStoreWithOut } from "@/store/modules/app";
import type { AxiosResponse } from "axios";
import type { Instance } from "@/types/selector";
interface AsyncProfilingState {
taskList: Array<Recordable<AsyncProfilingTaskList>>;
labels: Option[];
asyncProfilingTips: string;
selectedTask: Recordable<AsyncProfilingTaskList>;
taskProgress: Recordable<any>;
instances: Instance[];
}
export const asyncProfilingStore = defineStore({
@ -35,6 +39,8 @@ export const asyncProfilingStore = defineStore({
labels: [{ value: "", label: "" }],
asyncProfilingTips: "",
selectedTask: {},
taskProgress: {},
instances: [],
}),
actions: {
setSelectedTask(task: Recordable<AsyncProfilingTaskList>) {
@ -64,7 +70,21 @@ export const asyncProfilingStore = defineStore({
if (res.data.errors) {
return res.data;
}
this.taskLogs = res.data.data.taskLogs;
this.taskProgress = res.data.data.taskProgress;
return res.data;
},
async getServiceInstances(param?: { serviceId: string; isRelation: boolean }): Promise<Nullable<AxiosResponse>> {
const serviceId = param ? param.serviceId : this.currentService?.id;
if (!serviceId) {
return null;
}
const res: AxiosResponse = await graphql.query("queryInstances").params({
serviceId,
duration: useAppStoreWithOut().durationTime,
});
if (!res.data.errors) {
this.instances = res.data.data.pods || [];
}
return res.data;
},
},

View File

@ -41,6 +41,8 @@ export interface TaskListItem {
dumpPeriod: number;
maxSamplingCount: number;
logs: TaskLog[];
errorInstanceIds: string[];
successInstanceIds: string[];
}
export interface SegmentSpan {
spanId: string;

View File

@ -19,9 +19,21 @@ limitations under the License. -->
</div>
</template>
<script lang="ts" setup>
import { onMounted } from "vue";
import type { PropType } from "vue";
import { useI18n } from "vue-i18n";
import { ElMessage } from "element-plus";
import { useAsyncProfilingStore } from "@/store/modules/async-profiling";
const asyncProfilingStore = useAsyncProfilingStore();
onMounted(async () => {
const resp = await asyncProfilingStore.getServiceInstances();
if (resp.errors) {
ElMessage.error(resp.errors);
}
});
/* global defineProps */
defineProps({
config: {

View File

@ -102,6 +102,19 @@ limitations under the License. -->
</div>
</div>
</div>
<div>
<h5 class="mb-10 mt-10" v-show="errorInstances.length"> {{ t("errorInstanceIds") }}. </h5>
<div class="log-item" v-for="(instance, index) in errorInstances" :key="instance.value || index">
<div class="mb-10 sm">
<span class="mr-10 grey">{{ t("instance") }}:</span>
<span>{{ instance.label }}</span>
</div>
<div v-for="(d, index) in instance.attributes" :key="d.value + index">
<span class="mr-10 grey">{{ d.name }}:</span>
<span class="mr-20">{{ d.value }}</span>
</div>
</div>
</div>
</div>
</el-dialog>
</template>
@ -113,6 +126,7 @@ limitations under the License. -->
import type { TaskLog, TaskListItem } from "@/types/profile";
import { ElMessage } from "element-plus";
import { dateFormat } from "@/utils/dateFormat";
import type { Instance } from "@/types/selector";
const { t } = useI18n();
const asyncProfilingStore = useAsyncProfilingStore();
@ -121,6 +135,8 @@ limitations under the License. -->
const service = ref<string>("");
const selectedTask = ref<TaskListItem | Record<string, never>>({});
const instanceLogs = ref<TaskLog | any>({});
const errorInstances = ref<Instance[]>([]);
const successInstances = ref<Instance[]>([]);
async function changeTask(item: TaskListItem) {
asyncProfilingStore.setCurrentSegment({});
@ -138,7 +154,16 @@ limitations under the License. -->
ElMessage.error(res.errors);
return;
}
item.logs = asyncProfilingStore.taskLogs;
item = {
...item,
...asyncProfilingStore.taskProgress,
};
errorInstances.value = asyncProfilingStore.instances.filter(
(d: Instance) => d.id && item.errorInstanceIds.includes(d.id),
);
successInstances.value = asyncProfilingStore.instances.filter(
(d: Instance) => d.id && item.successInstanceIds.includes(d.id),
);
instanceLogs.value = {};
for (const d of item.logs) {
if (instanceLogs.value[d.instanceName]) {