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

View File

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