fix: update span tree

This commit is contained in:
Qiuxia Fan 2022-03-01 16:40:33 +08:00
parent bd43b92516
commit 1ea3e4a04a
9 changed files with 63 additions and 48 deletions

View File

@ -20,8 +20,8 @@ limitations under the License. -->
<Icon iconName="ellipsis_v" size="middle" class="operation" /> <Icon iconName="ellipsis_v" size="middle" class="operation" />
</span> </span>
</template> </template>
<div class="tools"> <div class="tools" @click="removeWidget">
<span @click="removeWidget">{{ t("delete") }}</span> <span>{{ t("delete") }}</span>
</div> </div>
</el-popover> </el-popover>
<Header /> <Header />

View File

@ -20,8 +20,8 @@ limitations under the License. -->
<Icon iconName="ellipsis_v" size="middle" class="operation" /> <Icon iconName="ellipsis_v" size="middle" class="operation" />
</span> </span>
</template> </template>
<div class="tools"> <div class="tools" @click="removeWidget">
<span @click="removeWidget">{{ t("delete") }}</span> <span>{{ t("delete") }}</span>
</div> </div>
</el-popover> </el-popover>
<div class="header"> <div class="header">

View File

@ -210,8 +210,8 @@ export const Status = [
{ label: "Error", value: "ERROR" }, { label: "Error", value: "ERROR" },
]; ];
export const QueryOrders = [ export const QueryOrders = [
{ label: "startTime", value: "BY_START_TIME" }, { label: "Start Time", value: "BY_START_TIME" },
{ label: "duration", value: "BY_DURATION" }, { label: "Duration", value: "BY_DURATION" },
]; ];
export const TraceEntitys = ["All", "Service", "ServiceInstance", "Endpoint"]; export const TraceEntitys = ["All", "Service", "ServiceInstance", "Endpoint"];
export const ProfileMode: any[] = [ export const ProfileMode: any[] = [

View File

@ -78,7 +78,7 @@ async function selectTrace(item: Trace) {
<style lang="scss" scoped> <style lang="scss" scoped>
.profile-trace-wrapper { .profile-trace-wrapper {
width: 300px; width: 300px;
height: calc((100% - 60px) / 2); height: 50%;
overflow: auto; overflow: auto;
.no-data { .no-data {

View File

@ -45,8 +45,8 @@ limitations under the License. -->
profileStore.currentSegment.traceIds[0] profileStore.currentSegment.traceIds[0]
" "
:showBtnDetail="true" :showBtnDetail="true"
:HeaderType="'profile'" headerType="profile"
@selectSpan="selectSpan" @select="selectSpan"
/> />
</div> </div>
</template> </template>

View File

@ -15,45 +15,45 @@ limitations under the License. -->
<template> <template>
<div> <div>
<h5 class="mb-15">{{ t("tags") }}.</h5> <h5 class="mb-15">{{ t("tags") }}.</h5>
<div class="mb-10 clear"> <div class="mb-10 clear item">
<span class="g-sm-4 grey">{{ t("service") }}:</span> <span class="g-sm-4 grey">{{ t("service") }}:</span>
<span class="g-sm-8 wba">{{ currentSpan.serviceCode }}</span> <span class="g-sm-8 wba">{{ currentSpan.serviceCode }}</span>
</div> </div>
<div class="mb-10 clear"> <div class="mb-10 clear item">
<span class="g-sm-4 grey">{{ t("instance") }}:</span> <span class="g-sm-4 grey">{{ t("instance") }}:</span>
<span class="g-sm-8 wba">{{ currentSpan.serviceInstanceName }}</span> <span class="g-sm-8 wba">{{ currentSpan.serviceInstanceName }}</span>
</div> </div>
<div class="mb-10 clear"> <div class="mb-10 clear item">
<span class="g-sm-4 grey">{{ t("endpoint") }}:</span> <span class="g-sm-4 grey">{{ t("endpoint") }}:</span>
<span class="g-sm-8 wba">{{ currentSpan.label }}</span> <span class="g-sm-8 wba">{{ currentSpan.label }}</span>
</div> </div>
<div class="mb-10 clear"> <div class="mb-10 clear item">
<span class="g-sm-4 grey">{{ t("spanType") }}:</span> <span class="g-sm-4 grey">{{ t("spanType") }}:</span>
<span class="g-sm-8 wba">{{ currentSpan.type }}</span> <span class="g-sm-8 wba">{{ currentSpan.type }}</span>
</div> </div>
<div class="mb-10 clear"> <div class="mb-10 clear item">
<span class="g-sm-4 grey">{{ t("component") }}:</span> <span class="g-sm-4 grey">{{ t("component") }}:</span>
<span class="g-sm-8 wba">{{ currentSpan.component }}</span> <span class="g-sm-8 wba">{{ currentSpan.component }}</span>
</div> </div>
<div class="mb-10 clear"> <div class="mb-10 clear item">
<span class="g-sm-4 grey">Peer:</span> <span class="g-sm-4 grey">Peer:</span>
<span class="g-sm-8 wba">{{ currentSpan.peer || "No Peer" }}</span> <span class="g-sm-8 wba">{{ currentSpan.peer || "No Peer" }}</span>
</div> </div>
<div class="mb-10 clear"> <div class="mb-10 clear item">
<span class="g-sm-4 grey">{{ t("error") }}:</span> <span class="g-sm-4 grey">{{ t("error") }}:</span>
<span class="g-sm-8 wba">{{ currentSpan.isError }}</span> <span class="g-sm-8 wba">{{ currentSpan.isError }}</span>
</div> </div>
<div class="mb-10 clear" v-for="i in currentSpan.tags" :key="i.key"> <div class="mb-10 clear item" v-for="i in currentSpan.tags" :key="i.key">
<span class="g-sm-4 grey">{{ i.key }}:</span> <span class="g-sm-4 grey">{{ i.key }}:</span>
<span class="g-sm-8 wba"> <span class="g-sm-8 wba">
{{ i.value }} {{ i.value }}
<svg <span
v-if="i.key === 'db.statement'" v-if="i.key === 'db.statement'"
class="icon vm grey link-hover cp ml-5" class="grey link-hover cp ml-5"
@click="copy(i.value)" @click="copy(i.value)"
> >
<use xlink:href="#review-list"></use> <Icon iconName="review-list" />
</svg> </span>
</span> </span>
</div> </div>
<h5 class="mb-10" v-if="currentSpan.logs" v-show="currentSpan.logs.length"> <h5 class="mb-10" v-if="currentSpan.logs" v-show="currentSpan.logs.length">
@ -71,20 +71,16 @@ limitations under the License. -->
class="r rk-sidebox-magnify" class="r rk-sidebox-magnify"
@click="showCurrentSpanDetail(_i.value)" @click="showCurrentSpanDetail(_i.value)"
> >
<svg class="icon"> <Icon iconName="magnify" />
<use xlink:href="#magnify"></use>
</svg>
</span> </span>
</div> </div>
<pre class="pl-15 mt-0 mb-0 sm oa">{{ _i.value }}</pre> <pre class="pl-15 mt-0 mb-0 sm oa">{{ _i.value }}</pre>
</div> </div>
</div> </div>
<div @click="getTaceLogs()"> <el-button class="popup-btn" type="primary" @click="getTaceLogs">
<el-button class="popup-btn" type="primary">
{{ t("relatedTraceLogs") }} {{ t("relatedTraceLogs") }}
</el-button> </el-button>
</div> </div>
</div>
<el-dialog <el-dialog
v-model="showRelatedLogs" v-model="showRelatedLogs"
:destroy-on-close="true" :destroy-on-close="true"
@ -132,6 +128,7 @@ const dateFormat = (date: number, pattern = "YYYY-MM-DD HH:mm:ss") =>
dayjs(date).format(pattern); dayjs(date).format(pattern);
async function getTaceLogs() { async function getTaceLogs() {
showRelatedLogs.value = true; showRelatedLogs.value = true;
console.log(props.currentSpan);
const res = await traceStore.getSpanLogs({ const res = await traceStore.getSpanLogs({
condition: { condition: {
relatedTrace: { relatedTrace: {
@ -161,4 +158,16 @@ function showCurrentSpanDetail(text: string) {
width: 100%; width: 100%;
text-align: center; text-align: center;
} }
.item span {
height: 21px;
}
.link-hover {
cursor: pointer;
}
.link-hover:hover {
color: #448dfe;
}
</style> </style>

View File

@ -20,7 +20,8 @@ limitations under the License. -->
<TableContainer <TableContainer
:tableData="tableData" :tableData="tableData"
type="table" type="table"
:HeaderType="HeaderType" :headerType="headerType"
@select="handleSelectSpan"
> >
<div class="trace-tips" v-if="!tableData.length">{{ $t("noData") }}</div> <div class="trace-tips" v-if="!tableData.length">{{ $t("noData") }}</div>
</TableContainer> </TableContainer>
@ -31,27 +32,26 @@ import { ref, watch, onMounted } from "vue";
import type { PropType } from "vue"; import type { PropType } from "vue";
import TableContainer from "./TableContainer.vue"; import TableContainer from "./TableContainer.vue";
import traceTable from "../../utils/trace-table"; import traceTable from "../../utils/trace-table";
import { Span } from "@/types/trace";
/* global defineProps, defineEmits */ /* global defineProps, defineEmits */
const props = defineProps({ const props = defineProps({
data: { type: Array as PropType<any>, default: () => [] }, data: { type: Array as PropType<any>, default: () => [] },
traceId: { type: String, default: "" }, traceId: { type: String, default: "" },
showBtnDetail: { type: Boolean, default: false }, showBtnDetail: { type: Boolean, default: false },
HeaderType: { type: String, default: "" }, headerType: { type: String, default: "" },
}); });
const emit = defineEmits(["select", "view", "load"]); const emit = defineEmits(["select", "view", "load"]);
const loading = ref<boolean>(true); const loading = ref<boolean>(true);
const tableData = ref<any>([]); const tableData = ref<any>([]);
const showDetail = ref<boolean>(false); const showDetail = ref<boolean>(false);
const currentSpan = ref<any[]>([]); const currentSpan = ref<Span | any>({});
onMounted(() => { onMounted(() => {
tableData.value = formatData( tableData.value = formatData(
traceTable.changeTree(props.data, props.traceId) traceTable.changeTree(props.data, props.traceId)
); );
loading.value = false; loading.value = false;
emit("select", handleSelectSpan);
emit("view", handleViewSpan);
emit("load", () => { emit("load", () => {
loading.value = true; loading.value = true;
}); });
@ -69,7 +69,7 @@ function formatData(arr: any[], level = 1, totalExec?: number) {
return arr; return arr;
} }
function handleSelectSpan(data: any[]) { function handleSelectSpan(data: Span) {
currentSpan.value = data; currentSpan.value = data;
if (!props.showBtnDetail) { if (!props.showBtnDetail) {
showDetail.value = true; showDetail.value = true;
@ -77,10 +77,6 @@ function handleSelectSpan(data: any[]) {
emit("select", data); emit("select", data);
} }
function handleViewSpan() {
showDetail.value = true;
}
watch( watch(
() => props.data, () => props.data,
() => { () => {

View File

@ -43,12 +43,14 @@ limitations under the License. -->
{{ item.value }} {{ item.value }}
</div> </div>
</div> </div>
<table-item <TableItem
:method="method" :method="method"
v-for="(item, index) in tableData" v-for="(item, index) in tableData"
:data="item" :data="item"
:key="'key' + index" :key="'key' + index"
:type="type" :type="type"
:headerType="headerType"
@click="selectItem(item)"
/> />
<slot></slot> <slot></slot>
</div> </div>
@ -56,21 +58,24 @@ limitations under the License. -->
<script lang="ts" setup> <script lang="ts" setup>
import { ref, onMounted } from "vue"; import { ref, onMounted } from "vue";
import type { PropType } from "vue"; import type { PropType } from "vue";
import { Span } from "@/types/trace";
import TableItem from "./TableItem.vue"; import TableItem from "./TableItem.vue";
import { ProfileConstant, TraceConstant, StatisticsConstant } from "./data"; import { ProfileConstant, TraceConstant, StatisticsConstant } from "./data";
/* global defineProps, Nullable */ /* global defineProps, Nullable, defineEmits */
const props = defineProps({ const props = defineProps({
tableData: { type: Array as PropType<any>, default: () => [] }, tableData: { type: Array as PropType<any>, default: () => [] },
type: { type: String, default: "" }, type: { type: String, default: "" },
HeaderType: { type: String, default: "" }, headerType: { type: String, default: "" },
}); });
const emits = defineEmits(["select"]);
const method = ref<number>(300); const method = ref<number>(300);
const componentKey = ref<number>(300); const componentKey = ref<number>(300);
const flag = ref<boolean>(true); const flag = ref<boolean>(true);
const dragger = ref<Nullable<HTMLSpanElement>>(null); const dragger = ref<Nullable<HTMLSpanElement>>(null);
let headerData: any[] = TraceConstant; let headerData: any[] = TraceConstant;
if (props.HeaderType === "profile") {
if (props.headerType === "profile") {
headerData = ProfileConstant; headerData = ProfileConstant;
} }
if (props.type === "statistics") { if (props.type === "statistics") {
@ -94,6 +99,9 @@ onMounted(() => {
}; };
}; };
}); });
function selectItem(span: Span) {
emits("select", span);
}
function sortStatistics(key: string) { function sortStatistics(key: string) {
const element = props.tableData; const element = props.tableData;
for (let i = 0; i < element.length; i++) { for (let i = 0; i < element.length; i++) {

View File

@ -143,13 +143,13 @@ const props = {
data: { type: Object as PropType<any>, default: () => ({}) }, data: { type: Object as PropType<any>, default: () => ({}) },
method: { type: Number, default: 0 }, method: { type: Number, default: 0 },
type: { type: String, default: "" }, type: { type: String, default: "" },
headerType: { type: String, default: "" },
}; };
export default defineComponent({ export default defineComponent({
name: "TableItem", name: "TableItem",
props, props,
emits: ["select"],
components: { SpanDetail }, components: { SpanDetail },
setup(props, { emit }) { setup(props) {
/* global Nullable */ /* global Nullable */
const displayChildren = ref<boolean>(true); const displayChildren = ref<boolean>(true);
const showDetail = ref<boolean>(false); const showDetail = ref<boolean>(false);
@ -193,12 +193,14 @@ export default defineComponent({
if (!traceItem.value) { if (!traceItem.value) {
return; return;
} }
traceItem.value.style.background = "rgba(0, 0, 0, 0.1)";
traceItem.value.style.background = "rgba(0, 0, 0, 1)";
} }
function viewSpanDetail() { function viewSpanDetail() {
showDetail.value = true;
showSelectSpan(); showSelectSpan();
emit("select", props.data); if (props.headerType === "trace") {
showDetail.value = true;
}
} }
watch( watch(