log associate with trace

This commit is contained in:
Qiuxia Fan 2022-07-27 10:46:19 +08:00
parent 04014a13be
commit 7712603706
4 changed files with 46 additions and 20 deletions

View File

@ -14,46 +14,68 @@ See the License for the specific language governing permissions and
limitations under the License. -->
<template>
<div @click="showSelectSpan" class="log-item">
<div class="log-item">
<div v-for="(item, index) in columns" :key="index" :class="item.label">
<span v-if="item.label === 'timestamp'">
<span v-if="item.label === 'timestamp'" @click="showSelectSpan">
{{ dateFormat(data.timestamp) }}
</span>
<span v-else-if="item.label === 'tags'">
<span v-else-if="item.label === 'tags'" @click="showSelectSpan">
{{ tags }}
</span>
<!-- <router-link
<span
v-else-if="item.label === 'traceId' && !noLink"
:to="{ name: 'trace', query: { traceid: data[item.label] } }"
:class="noLink ? '' : 'blue'"
@click="linkTrace(data[item.label])"
>
<span :class="noLink ? '' : 'blue'">{{ data[item.label] }}</span>
</router-link> -->
<span v-else>{{ data[item.label] }}</span>
{{ data[item.label] }}
</span>
<span v-else @click="showSelectSpan">{{ data[item.label] }}</span>
</div>
</div>
</template>
<script lang="ts" setup>
import { computed } from "vue";
import { computed, inject } from "vue";
import dayjs from "dayjs";
import { ServiceLogConstants } from "./data";
/*global defineProps, defineEmits */
import getDashboard from "@/hooks/useDashboardsSession";
import { useDashboardStore } from "@/store/modules/dashboard";
import { LayoutConfig } from "@/types/dashboard";
/*global defineProps, defineEmits, Recordable */
const props = defineProps({
data: { type: Object as any, default: () => ({}) },
noLink: { type: Boolean, default: true },
});
const dashboardStore = useDashboardStore();
const options: Recordable<LayoutConfig> = inject("options") || {};
const emit = defineEmits(["select"]);
const columns = ServiceLogConstants;
const tags = computed(() => {
if (!props.data.tags) {
return "";
}
return String(props.data.tags.map((d: any) => `${d.key}=${d.value}`));
return String(
props.data.tags.map(
(d: { key: string; value: string }) => `${d.key}=${d.value}`
)
);
});
const dateFormat = (date: number, pattern = "YYYY-MM-DD HH:mm:ss") =>
dayjs(date).format(pattern);
function showSelectSpan() {
emit("select", props.data);
}
function linkTrace(id: string) {
const { associationWidget } = getDashboard(dashboardStore.currentDashboard);
associationWidget(
(options.id as any) || "",
{
sourceId: options.id || "",
traceId: id,
},
"Trace"
);
}
</script>
<style lang="scss" scoped>
.log-item {

View File

@ -40,14 +40,14 @@ export const ServiceLogConstants = [
label: "tags",
value: "tags",
},
{
label: "content",
value: "content",
},
{
label: "traceId",
value: "traceID",
},
{
label: "content",
value: "content",
},
];
export const ServiceLogDetail = [
{

View File

@ -18,7 +18,7 @@ limitations under the License. -->
v-loading="logStore.loadLogs"
:tableData="logStore.logs || []"
:type="type"
:noLink="true"
:noLink="false"
>
<div class="log-tips" v-if="!logStore.logs.length">{{ t("noData") }}</div>
</LogTable>

View File

@ -92,7 +92,7 @@ limitations under the License. -->
</div>
</template>
<script lang="ts" setup>
import { ref, reactive, watch } from "vue";
import { ref, reactive, watch, inject } from "vue";
import { useI18n } from "vue-i18n";
import { Option } from "@/types/app";
import { Status } from "../../data";
@ -103,8 +103,10 @@ import { useSelectorStore } from "@/store/modules/selectors";
import ConditionTags from "@/views/components/ConditionTags.vue";
import { ElMessage } from "element-plus";
import { EntityType } from "../../data";
import { LayoutConfig } from "@/types/dashboard";
/*global defineProps */
/*global defineProps, Recordable */
const options: LayoutConfig | undefined = inject("options");
const props = defineProps({
needQuery: { type: Boolean, default: true },
});
@ -113,12 +115,14 @@ const appStore = useAppStoreWithOut();
const selectorStore = useSelectorStore();
const dashboardStore = useDashboardStore();
const traceStore = useTraceStore();
const traceId = ref<string>("");
const traceId = ref<string>(
(options && options.filters && options.filters.traceId) || ""
);
const minTraceDuration = ref<number>();
const maxTraceDuration = ref<number>();
const tagsList = ref<string[]>([]);
const tagsMap = ref<Option[]>([]);
const state = reactive<any>({
const state = reactive<Recordable>({
status: { label: "All", value: "ALL" },
instance: { value: "0", label: "All" },
endpoint: { value: "0", label: "All" },