From 2c1e8511e718cac8f6e5b01ad719302e588ad092 Mon Sep 17 00:00:00 2001 From: Fine0830 Date: Mon, 27 Apr 2026 19:04:47 +0800 Subject: [PATCH] feat: support trace v1 in trace single page (#549) --- src/store/modules/trace.ts | 28 +++++++++++++++++-- src/views/dashboard/Trace.vue | 21 ++++++++------ .../trace/components/TraceList/SpanList.vue | 2 ++ 3 files changed, 39 insertions(+), 12 deletions(-) diff --git a/src/store/modules/trace.ts b/src/store/modules/trace.ts index 3b60299b..eae5d476 100644 --- a/src/store/modules/trace.ts +++ b/src/store/modules/trace.ts @@ -177,10 +177,10 @@ export const traceStore = defineStore({ return response; }, async getTraces() { + this.loading = true; if (this.hasQueryTracesV2Support) { return this.fetchV2Traces(); } - this.loading = true; const response = await graphql.query("queryTraces").params({ condition: this.conditions }); if (response.errors) { this.loading = false; @@ -193,14 +193,15 @@ export const traceStore = defineStore({ this.loading = false; return response; } - this.getTraceSpans({ traceId: response.data.data.traces[0].traceIds[0] }); this.traceList = response.data.data.traces.map((d: Trace) => { d.traceIds = d.traceIds.map((id: string) => { return { value: id, label: id }; }); return d; }); - this.setCurrentTrace(response.data.data.traces[0] || {}); + const currentTrace = this.traceList[0] || {}; + this.setCurrentTrace(currentTrace); + await this.getTraceSpans({ traceId: currentTrace.traceIds?.[0]?.value || "" }); return response; }, async getTraceSpans(params: { traceId: string }) { @@ -301,6 +302,27 @@ export const traceStore = defineStore({ this.setCurrentTrace(trace || {}); return response; }, + + async getTraceByTraceId(traceId: string) { + this.loading = true; + this.setTraceCondition({ + traceId: traceId, + }); + await this.getHasQueryTracesV2Support(); + if (this.hasQueryTracesV2Support) { + await this.fetchV2Traces(); + this.loading = false; + return; + } + this.setCurrentTrace({ + traceIds: [{ value: traceId, label: traceId }], + traceId: traceId, + endpointNames: [], + spans: [], + }); + await this.getTraceSpans({ traceId }); + this.loading = false; + }, }, }); diff --git a/src/views/dashboard/Trace.vue b/src/views/dashboard/Trace.vue index 705e6875..0e36b106 100644 --- a/src/views/dashboard/Trace.vue +++ b/src/views/dashboard/Trace.vue @@ -14,10 +14,14 @@ See the License for the specific language governing permissions and limitations under the License. --> @@ -26,17 +30,16 @@ limitations under the License. --> import { computed, onMounted, provide } from "vue"; import { useTraceStore } from "@/store/modules/trace"; import TraceContent from "@/views/dashboard/related/trace/components/TraceQuery/TraceContent.vue"; + import SpanList from "@/views/dashboard/related/trace/components/TraceList/SpanList.vue"; const route = useRoute(); const traceStore = useTraceStore(); const traceId = computed(() => route.params.traceId as string); provide("options", {}); onMounted(() => { - if (traceId.value) { - traceStore.setTraceCondition({ - traceId: traceId.value, - }); - traceStore.fetchV2Traces(); + if (!traceId.value) { + return; } + traceStore.getTraceByTraceId(traceId.value); }); diff --git a/src/views/dashboard/related/trace/components/TraceList/SpanList.vue b/src/views/dashboard/related/trace/components/TraceList/SpanList.vue index f33ea8d4..a277b6f4 100644 --- a/src/views/dashboard/related/trace/components/TraceList/SpanList.vue +++ b/src/views/dashboard/related/trace/components/TraceList/SpanList.vue @@ -67,6 +67,8 @@ limitations under the License. --> :traceId="traceStore.currentTrace?.traceIds?.[0]?.value" :showBtnDetail="false" :headerType="WidgetType.Trace" + :minTimestamp="NaN" + :maxTimestamp="NaN" />