feat: update timeline

This commit is contained in:
Fine 2023-06-06 17:18:26 +08:00
parent 51cf096d90
commit d7bc79310d
2 changed files with 44 additions and 13 deletions

19
src/types/ebpf.d.ts vendored
View File

@ -28,12 +28,31 @@ export interface EBPFTaskList {
taskId: string; taskId: string;
serviceName: string; serviceName: string;
serviceId: string; serviceId: string;
serviceInstanceId: string;
serviceInstanceName: string;
processId: string;
processName: string;
processLabels: string[]; processLabels: string[];
taskStartTime: number; taskStartTime: number;
fixedTriggerDuration: number; fixedTriggerDuration: number;
targetType: string; targetType: string;
createTime: number; createTime: number;
triggerType: string; triggerType: string;
continuousProfilingCauses: ProfilingCause[];
}
interface ProfilingCause {
type: string;
singleValue: {
threshold: number;
current: number;
};
uri: {
uriRegex: string;
uriPath: string;
threshold: number;
current: number;
};
} }
export interface EBPFProfilingSchedule { export interface EBPFProfilingSchedule {

View File

@ -77,7 +77,7 @@ limitations under the License. -->
visGraph.value.destroy(); visGraph.value.destroy();
} }
const h = timeline.value.getBoundingClientRect().height; const h = timeline.value.getBoundingClientRect().height;
const events = taskTimelineStore.events.map((d: EBPFTaskList, index: number) => { const taskList = taskTimelineStore.taskList.map((d: EBPFTaskList, index: number) => {
return { return {
id: index + 1, id: index + 1,
content: d.triggerType, content: d.triggerType,
@ -87,7 +87,7 @@ limitations under the License. -->
className: d.targetType, className: d.targetType,
}; };
}); });
const items: any = new DataSet(events); const items: any = new DataSet(taskList);
const options: any = { const options: any = {
height: h, height: h,
width: "100%", width: "100%",
@ -96,25 +96,38 @@ limitations under the License. -->
autoResize: false, autoResize: false,
tooltip: { tooltip: {
overflowMethod: "cap", overflowMethod: "cap",
template(item: Event | any) { template(item: EBPFTaskList | any) {
const data = item.data || {}; const data = item.data || {};
let tmp = `<div>ID: ${data.uuid || ""}</div> let tmp = `
<div>Name: ${data.name || ""}</div> <div>Task ID: ${data.taskId || ""}</div>
<div>Event Type: ${data.type || ""}</div> <div>Service Name: ${data.serviceName || ""}</div>
<div>Start Time: ${data.startTime ? visDate(data.startTime) : ""}</div> <div>Service Instance Name: ${data.serviceInstanceName || ""}</div>
<div>End Time: ${data.endTime ? visDate(data.endTime) : ""}</div> <div>Service Process Name: ${data.processName || ""}</div>
<div>Message: ${data.message || ""}</div> <div>Trigger Type: ${data.triggerType || ""}</div>
<div>Service: ${data.source.service || ""}</div>`; <div>Target Type: ${data.targetType || ""}</div>
return tmp; <div>Start Time: ${data.startTime ? visDate(data.startTime) : ""}</div>
<div>End Time: ${data.endTime ? visDate(data.endTime) : ""}</div>
<div>Process Labels: ${data.processLabels.join("; ") || ""}</div>`;
let str = "";
for (const item of data.continuousProfilingCauses) {
str += `<div>${item.type}: ${getURI(item.uri)}${item.uri.threshold}>=${item.uri.current}</div>`;
}
return tmp + str;
}, },
}, },
}; };
visGraph.value = new Timeline(timeline.value, items, options); visGraph.value = new Timeline(timeline.value, items, options);
visGraph.value.on("select", (properties: { items: number[] }) => { visGraph.value.on("select", (properties: { items: number[] }) => {
dashboardStore.selectWidget(props.data); dashboardStore.selectWidget(props.data);
const index = items[0];
taskTimelineStore.setSelectedTask(taskList[index]);
}); });
} }
function getURI(uri: { uriRegex: string; uriPath: string }) {
return uri ? `(${uri.uriRegex || ""} | ${uri.uriPath || ""})` : "";
}
function resize() { function resize() {
const observer = new ResizeObserver((entries) => { const observer = new ResizeObserver((entries) => {
const entry = entries[0]; const entry = entries[0];
@ -140,8 +153,7 @@ limitations under the License. -->
.task-timeline { .task-timeline {
width: calc(100% - 5px); width: calc(100% - 5px);
margin: 0 5px 5px 0; margin: 0 5px 5px 0;
height: 100%; height: 300px;
min-height: 150px;
} }
.message { .message {