fix: update profiling

This commit is contained in:
Fine 2023-03-28 22:05:24 +08:00
parent bdd376ffb3
commit e02f91deef
3 changed files with 18 additions and 4 deletions

View File

@ -69,6 +69,7 @@ export const profileStore = defineStore({
}, },
setCurrentTask(task: TaskListItem) { setCurrentTask(task: TaskListItem) {
this.currentTask = task || {}; this.currentTask = task || {};
this.analyzeTrees = [];
}, },
setSegmentSpans(spans: Recordable<SegmentSpan>[]) { setSegmentSpans(spans: Recordable<SegmentSpan>[]) {
const index = spans.length - 1 || 0; const index = spans.length - 1 || 0;
@ -77,9 +78,18 @@ export const profileStore = defineStore({
}, },
setCurrentSpan(span: Recordable<SegmentSpan>) { setCurrentSpan(span: Recordable<SegmentSpan>) {
this.currentSpan = span; this.currentSpan = span;
this.analyzeTrees = [];
}, },
setCurrentSegment(s: Recordable<Trace>) { setCurrentSegment(segment: Trace) {
this.currentSegment = s; this.currentSegment = segment;
this.segmentSpans = segment.spans || [];
if (segment.spans) {
const index = segment.spans.length - 1 || 0;
this.currentSpan = segment.spans[index];
} else {
this.currentSpan = {};
}
this.analyzeTrees = [];
}, },
setHighlightTop() { setHighlightTop() {
this.highlightTop = !this.highlightTop; this.highlightTop = !this.highlightTop;

View File

@ -20,7 +20,7 @@ limitations under the License. -->
{{ t("noData") }} {{ t("noData") }}
</div> </div>
<table class="profile-t"> <table class="profile-t">
<tr class="profile-tr cp" v-for="(i, index) in profileStore.segmentList" @click="selectTrace(i)" :key="index"> <tr class="profile-tr cp" v-for="(i, index) in profileStore.segmentList" @click="selectSegment(i)" :key="index">
<td <td
class="profile-td" class="profile-td"
:class="{ :class="{
@ -57,7 +57,7 @@ limitations under the License. -->
const profileStore = useProfileStore(); const profileStore = useProfileStore();
const key = computed(() => (profileStore.currentSpan && profileStore.currentSpan.segmentId) || ""); const key = computed(() => (profileStore.currentSpan && profileStore.currentSpan.segmentId) || "");
async function selectTrace(item: Trace) { async function selectSegment(item: Trace) {
profileStore.setCurrentSegment(item); profileStore.setCurrentSegment(item);
profileStore.setSegmentSpans(item.spans); profileStore.setSegmentSpans(item.spans);
} }

View File

@ -69,6 +69,10 @@ limitations under the License. -->
} }
async function analyzeProfile() { async function analyzeProfile() {
if (!profileStore.currentSpan.profiled) {
ElMessage.info("It's a un-profiled span");
return;
}
emits("loading", true); emits("loading", true);
updateTimeRange(); updateTimeRange();
const params = timeRange.value.map((t: { start: number; end: number }) => { const params = timeRange.value.map((t: { start: number; end: number }) => {