polish ebpf

This commit is contained in:
Qiuxia Fan 2022-05-21 17:22:46 +08:00
parent 3b886d9897
commit 6ffd2a4673
4 changed files with 29 additions and 10 deletions

View File

@ -35,6 +35,7 @@ interface EbpfStore {
labels: Option[]; labels: Option[];
couldProfiling: boolean; couldProfiling: boolean;
tip: string; tip: string;
selectedTask: Recordable<EBPFTaskList>;
} }
export const ebpfStore = defineStore({ export const ebpfStore = defineStore({
@ -47,10 +48,11 @@ export const ebpfStore = defineStore({
labels: [{ value: "", label: "" }], labels: [{ value: "", label: "" }],
couldProfiling: false, couldProfiling: false,
tip: "", tip: "",
selectedTask: {},
}), }),
actions: { actions: {
setCurrentSpan(span: Span) { setSelectedTask(task: EBPFTaskList) {
this.currentSpan = span; this.selectedTask = task;
}, },
setCurrentSchedule(s: Trace) { setCurrentSchedule(s: Trace) {
this.currentSchedule = s; this.currentSchedule = s;

View File

@ -27,6 +27,7 @@ limitations under the License. -->
</div> </div>
<div class="flex-h"> <div class="flex-h">
<Selector <Selector
v-if="ebpfStore.selectedTask.targetType === 'OFF_CPU'"
:value="aggregateType" :value="aggregateType"
:options="AggregateTypes" :options="AggregateTypes"
size="small" size="small"
@ -34,11 +35,11 @@ limitations under the License. -->
@change="changeAggregateType" @change="changeAggregateType"
class="selector mr-10" class="selector mr-10"
/> />
<el-button type="primary" size="small"> <div class="mr-5 duration" v-if="duration.length">
<span>{{ duration[0] }}</span> <span>{{ duration[0] }}</span>
<span> ~ </span> <span> ~ </span>
<span>{{ duration[1] }}</span> <span>{{ duration[1] }}</span>
</el-button> </div>
<el-popover placement="bottom" :width="680" trigger="click"> <el-popover placement="bottom" :width="680" trigger="click">
<template #reference> <template #reference>
<el-button type="primary" size="small"> <el-button type="primary" size="small">
@ -189,10 +190,14 @@ function visTimeline() {
processes.value.push(d.process); processes.value.push(d.process);
return [d.startTime / 10000, d.endTime / 10000]; return [d.startTime / 10000, d.endTime / 10000];
}); });
const arr = ranges.flat(1); if (ranges.length) {
const min = Math.min(...arr); const arr = ranges.flat(1);
const max = Math.max(...arr); const min = Math.min(...arr);
duration.value = [dateFormat(min * 10000), dateFormat(max * 10000)]; const max = Math.max(...arr);
duration.value = [dateFormat(min * 10000), dateFormat(max * 10000)];
} else {
duration.value = [];
}
searchProcesses(0); searchProcesses(0);
} }
@ -269,4 +274,8 @@ watch(
.selector { .selector {
width: 120px; width: 120px;
} }
.duration {
line-height: 24px;
}
</style> </style>

View File

@ -34,7 +34,13 @@ limitations under the License. -->
}" }"
> >
<div class="ell"> <div class="ell">
<span>{{ i.processLabels.join(" ") || "No Labels" }}</span> <span>
{{
i.processLabels.length
? i.targetType + ": " + i.processLabels.join(" ")
: `All Processes`
}}
</span>
<a class="profile-btn r" @click="viewDetail = true"> <a class="profile-btn r" @click="viewDetail = true">
<Icon iconName="view" size="middle" /> <Icon iconName="view" size="middle" />
</a> </a>
@ -117,6 +123,7 @@ const viewDetail = ref<boolean>(false);
async function changeTask(item: EBPFTaskList) { async function changeTask(item: EBPFTaskList) {
selectedTask.value = item; selectedTask.value = item;
ebpfStore.setSelectedTask(item);
const res = await ebpfStore.getEBPFSchedules({ const res = await ebpfStore.getEBPFSchedules({
taskId: item.taskId, taskId: item.taskId,
}); });
@ -128,6 +135,7 @@ watch(
() => ebpfStore.taskList, () => ebpfStore.taskList,
() => { () => {
selectedTask.value = ebpfStore.taskList[0] || {}; selectedTask.value = ebpfStore.taskList[0] || {};
ebpfStore.setSelectedTask(selectedTask.value);
} }
); );
</script> </script>

View File

@ -34,8 +34,8 @@ export const TargetTypes = [
]; ];
export const AggregateTypes = [ export const AggregateTypes = [
{ label: "Duration", value: "DURATION" },
{ label: "Count", value: "COUNT" }, { label: "Count", value: "COUNT" },
{ label: "Duration", value: "DURATION" },
]; ];
export const InitTaskField = { export const InitTaskField = {