mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-10-14 20:01:28 +00:00
feat: update trace profiling protocol (#250)
This commit is contained in:
@@ -34,6 +34,7 @@ interface ProfileState {
|
||||
taskEndpoints: Endpoint[];
|
||||
condition: { serviceId: string; endpointName: string };
|
||||
taskList: TaskListItem[];
|
||||
currentTask: Recordable<TaskListItem>;
|
||||
segmentList: Trace[];
|
||||
currentSegment: Recordable<Trace>;
|
||||
segmentSpans: Array<Recordable<SegmentSpan>>;
|
||||
@@ -51,6 +52,7 @@ export const profileStore = defineStore({
|
||||
condition: { serviceId: "", endpointName: "" },
|
||||
taskList: [],
|
||||
segmentList: [],
|
||||
currentTask: {},
|
||||
currentSegment: {},
|
||||
segmentSpans: [],
|
||||
currentSpan: {},
|
||||
@@ -65,11 +67,27 @@ export const profileStore = defineStore({
|
||||
...data,
|
||||
};
|
||||
},
|
||||
setCurrentTask(task: TaskListItem) {
|
||||
this.currentTask = task || {};
|
||||
this.analyzeTrees = [];
|
||||
},
|
||||
setSegmentSpans(spans: Recordable<SegmentSpan>[]) {
|
||||
this.currentSpan = spans[0] || {};
|
||||
this.segmentSpans = spans;
|
||||
},
|
||||
setCurrentSpan(span: Recordable<SegmentSpan>) {
|
||||
this.currentSpan = span;
|
||||
this.analyzeTrees = [];
|
||||
},
|
||||
setCurrentSegment(s: Recordable<Trace>) {
|
||||
this.currentSegment = s;
|
||||
setCurrentSegment(segment: Trace) {
|
||||
this.currentSegment = segment;
|
||||
this.segmentSpans = segment.spans || [];
|
||||
if (segment.spans) {
|
||||
this.currentSpan = segment.spans[0] || {};
|
||||
} else {
|
||||
this.currentSpan = {};
|
||||
}
|
||||
this.analyzeTrees = [];
|
||||
},
|
||||
setHighlightTop() {
|
||||
this.highlightTop = !this.highlightTop;
|
||||
@@ -104,8 +122,9 @@ export const profileStore = defineStore({
|
||||
if (res.data.errors) {
|
||||
return res.data;
|
||||
}
|
||||
const list = res.data.data.taskList;
|
||||
const list = res.data.data.taskList || [];
|
||||
this.taskList = list;
|
||||
this.currentTask = list[0] || {};
|
||||
if (!list.length) {
|
||||
this.segmentList = [];
|
||||
this.segmentSpans = [];
|
||||
@@ -128,7 +147,7 @@ export const profileStore = defineStore({
|
||||
}
|
||||
const { segmentList } = res.data.data;
|
||||
|
||||
this.segmentList = segmentList;
|
||||
this.segmentList = segmentList || [];
|
||||
if (!segmentList.length) {
|
||||
this.segmentSpans = [];
|
||||
this.analyzeTrees = [];
|
||||
@@ -137,50 +156,22 @@ export const profileStore = defineStore({
|
||||
}
|
||||
if (segmentList[0]) {
|
||||
this.currentSegment = segmentList[0];
|
||||
this.getSegmentSpans({ segmentId: segmentList[0].segmentId });
|
||||
this.getSegmentSpans(segmentList[0].segmentId);
|
||||
} else {
|
||||
this.currentSegment = {};
|
||||
}
|
||||
return res.data;
|
||||
},
|
||||
async getSegmentSpans(params: { segmentId: string }) {
|
||||
if (!params.segmentId) {
|
||||
return new Promise((resolve) => resolve({}));
|
||||
}
|
||||
const res: AxiosResponse = await graphql.query("queryProfileSegment").params(params);
|
||||
if (res.data.errors) {
|
||||
this.segmentSpans = [];
|
||||
return res.data;
|
||||
}
|
||||
const { segment } = res.data.data;
|
||||
if (!segment) {
|
||||
this.segmentSpans = [];
|
||||
this.analyzeTrees = [];
|
||||
return res.data;
|
||||
}
|
||||
this.segmentSpans = segment.spans.map((d: SegmentSpan) => {
|
||||
return {
|
||||
...d,
|
||||
segmentId: this.currentSegment?.segmentId,
|
||||
traceId: (this.currentSegment.traceIds as any)[0],
|
||||
};
|
||||
});
|
||||
if (!(segment.spans && segment.spans.length)) {
|
||||
this.analyzeTrees = [];
|
||||
return res.data;
|
||||
}
|
||||
const index = segment.spans.length - 1 || 0;
|
||||
this.currentSpan = segment.spans[index];
|
||||
return res.data;
|
||||
async getSegmentSpans() {
|
||||
this.analyzeTrees = [];
|
||||
this.segmentSpans = this.currentSegment.spans;
|
||||
this.currentSpan = this.currentSegment.spans[0] || {};
|
||||
},
|
||||
async getProfileAnalyze(params: { segmentId: string; timeRanges: Array<{ start: number; end: number }> }) {
|
||||
if (!params.segmentId) {
|
||||
async getProfileAnalyze(params: Array<{ segmentId: string; timeRange: { start: number; end: number } }>) {
|
||||
if (!params.length) {
|
||||
return new Promise((resolve) => resolve({}));
|
||||
}
|
||||
if (!params.timeRanges.length) {
|
||||
return new Promise((resolve) => resolve({}));
|
||||
}
|
||||
const res: AxiosResponse = await graphql.query("getProfileAnalyze").params(params);
|
||||
const res: AxiosResponse = await graphql.query("getProfileAnalyze").params({ queries: params });
|
||||
|
||||
if (res.data.errors) {
|
||||
this.analyzeTrees = [];
|
||||
|
Reference in New Issue
Block a user