feat: update

This commit is contained in:
Fine 2023-03-28 17:22:12 +08:00
parent 1d8851c7cc
commit f54b2a0662
2 changed files with 7 additions and 34 deletions

View File

@ -148,23 +148,15 @@ export const profileStore = defineStore({
}, },
async getSegmentSpans() { async getSegmentSpans() {
this.analyzeTrees = []; this.analyzeTrees = [];
this.segmentSpans = this.currentSegment.spans.map((d: SegmentSpan) => { this.segmentSpans = this.currentSegment.spans;
return {
...d,
// traceId: (this.currentSegment.traceIds as any)[0],
};
});
const index = this.currentSegment.spans.length - 1 || 0; const index = this.currentSegment.spans.length - 1 || 0;
this.currentSpan = this.currentSegment.spans[index]; this.currentSpan = this.currentSegment.spans[index];
}, },
async getProfileAnalyze(params: Array<{ segmentId: string; timeRange: { start: number; end: number } }>) { async getProfileAnalyze(params: Array<{ segmentId: string; timeRange: { start: number; end: number } }>) {
// if (!params.segmentId) {
// return new Promise((resolve) => resolve({}));
// }
if (!params.length) { if (!params.length) {
return new Promise((resolve) => resolve({})); 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) { if (res.data.errors) {
this.analyzeTrees = []; this.analyzeTrees = [];

View File

@ -15,14 +15,6 @@ limitations under the License. -->
<template> <template>
<div class="profile-trace-dashboard" v-if="profileStore.currentSegment"> <div class="profile-trace-dashboard" v-if="profileStore.currentSegment">
<div class="profile-trace-detail-wrapper"> <div class="profile-trace-detail-wrapper">
<Selector
size="small"
:value="traceId || (traceIds[0] && traceIds[0].value) || ''"
:options="traceIds"
placeholder="Select a trace id"
@change="changeTraceId"
class="profile-trace-detail-ids mr-10"
/>
<Selector <Selector
size="small" size="small"
:value="mode" :value="mode"
@ -38,7 +30,7 @@ limitations under the License. -->
<div class="profile-table"> <div class="profile-table">
<Table <Table
:data="profileStore.segmentSpans" :data="profileStore.segmentSpans"
:traceId="profileStore.currentSegment.traceIds && profileStore.currentSegment.traceIds[0]" :traceId="profileStore.currentSegment.traceId"
:showBtnDetail="true" :showBtnDetail="true"
headerType="profile" headerType="profile"
@select="selectSpan" @select="selectSpan"
@ -47,7 +39,7 @@ limitations under the License. -->
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, computed } from "vue"; import { ref } from "vue";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import Table from "../../trace/components/Table/Index.vue"; import Table from "../../trace/components/Table/Index.vue";
import { useProfileStore } from "@/store/modules/profile"; import { useProfileStore } from "@/store/modules/profile";
@ -64,13 +56,6 @@ limitations under the License. -->
const mode = ref<string>("include"); const mode = ref<string>("include");
const message = ref<string>(""); const message = ref<string>("");
const timeRange = ref<Array<{ start: number; end: number }>>([]); const timeRange = ref<Array<{ start: number; end: number }>>([]);
const traceId = ref<string>("");
const traceIds = computed(() =>
(profileStore.currentSegment.traceIds || []).map((id: string) => ({
label: id,
value: id,
})),
);
function selectSpan(span: Span) { function selectSpan(span: Span) {
profileStore.setCurrentSpan(span); profileStore.setCurrentSpan(span);
@ -81,20 +66,16 @@ limitations under the License. -->
updateTimeRange(); updateTimeRange();
} }
function changeTraceId(opt: Option[]) {
traceId.value = opt[0].value;
}
async function analyzeProfile() { async function analyzeProfile() {
emits("loading", true); emits("loading", true);
updateTimeRange(); updateTimeRange();
const param = timeRange.value.map((t: { start: number; end: number }) => { const params = timeRange.value.map((t: { start: number; end: number }) => {
return { return {
segmentId: profileStore.currentSegment.segmentId, segmentId: profileStore.currentSpan.segmentId,
timeRange: t, timeRange: t,
}; };
}); });
const res = await profileStore.getProfileAnalyze(param); const res = await profileStore.getProfileAnalyze(params);
emits("loading", false); emits("loading", false);
if (res.errors) { if (res.errors) {
ElMessage.error(res.errors); ElMessage.error(res.errors);