From df9fe534c88c6b2633111d32ed3f74df78fdcaed Mon Sep 17 00:00:00 2001 From: kl7sn Date: Wed, 22 Nov 2023 00:39:49 +0800 Subject: [PATCH] feat: Log field length greater than 50k is not parsed Signed-off-by: kl7sn --- .github/workflows/apis.yml | 2 +- api/internal/router/router.go | 6 ++++-- ui/src/components/JsonView/JsonStringValue/index.tsx | 5 ++++- ui/src/config/config.ts | 1 + .../DataSourceMenu/LogLibraryList/DatabaseItem/index.tsx | 8 ++++++-- .../DataSourceMenu/LogLibraryList/InstanceItem/index.tsx | 7 ++++++- 6 files changed, 22 insertions(+), 7 deletions(-) diff --git a/.github/workflows/apis.yml b/.github/workflows/apis.yml index a67e021ab..a302ad459 100644 --- a/.github/workflows/apis.yml +++ b/.github/workflows/apis.yml @@ -20,7 +20,7 @@ jobs: run: | export PATH=$(go env GOPATH)/bin:$PATH go version - go install github.com/gotomicro/eapi/cmd/eapi@main + go install github.com/gotomicro/eapi/cmd/eapi@v0.4.6 eapi --config eapi.yaml - name: install redoc run: npm i -g redoc-cli diff --git a/api/internal/router/router.go b/api/internal/router/router.go index 85d3d735d..e9a80077b 100644 --- a/api/internal/router/router.go +++ b/api/internal/router/router.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" "strings" + "time" "github.com/gotomicro/ego/core/econf" "github.com/gotomicro/ego/server/egin" @@ -38,9 +39,10 @@ func GetServerRouter() *egin.Component { } maxAge := econf.GetInt("server.http.maxAge") if maxAge == 0 { - maxAge = 86400 + maxAge = 31536000 } - c.Header("Cache-Control", fmt.Sprintf("public, max-age=%d", maxAge)) + c.Header("Cache-Control", fmt.Sprintf("public, max-age=%d, public", maxAge)) + c.Header("Expires", time.Now().AddDate(1, 0, 0).Format("Mon, 01 Jan 2006 00:00:00 GMT")) path := strings.Replace(c.Request.URL.Path, appSubUrl, "", 1) c.FileFromFS(path, invoker.Gin.HTTPEmbedFs()) })) diff --git a/ui/src/components/JsonView/JsonStringValue/index.tsx b/ui/src/components/JsonView/JsonStringValue/index.tsx index 12f723617..e1ae1e337 100644 --- a/ui/src/components/JsonView/JsonStringValue/index.tsx +++ b/ui/src/components/JsonView/JsonStringValue/index.tsx @@ -1,6 +1,6 @@ import jsonViewStyles from "@/components/JsonView/index.less"; import classNames from "classnames"; -import { LOGMAXTEXTLENGTH } from "@/config/config"; +import {LOGMAXTEXTLENGTH, LOGMAXTEXTLENGTHUnParse} from "@/config/config"; import { Button, message } from "antd"; import { useState } from "react"; import { useIntl } from "umi"; @@ -205,6 +205,9 @@ const JsonStringValue = ({ }; const splitRawLogString = (str: string): string[] => { + if(str.length>LOGMAXTEXTLENGTHUnParse){ + return [str] + } const result: string[] = []; const strLen = str.length; diff --git a/ui/src/config/config.ts b/ui/src/config/config.ts index 9e40945e6..4b5ffb8c1 100644 --- a/ui/src/config/config.ts +++ b/ui/src/config/config.ts @@ -69,6 +69,7 @@ export const LANG_CN = "zh-CN"; // 不展开日志最大长度 export const LOGMAXTEXTLENGTH = 500; +export const LOGMAXTEXTLENGTHUnParse = 5120; // // 默认链路日志查询条数 export const LINKLOGS_PAGESIZE = 50; diff --git a/ui/src/pages/DataLogs/components/DataSourceMenu/LogLibraryList/DatabaseItem/index.tsx b/ui/src/pages/DataLogs/components/DataSourceMenu/LogLibraryList/DatabaseItem/index.tsx index 12956913e..cf2273f09 100644 --- a/ui/src/pages/DataLogs/components/DataSourceMenu/LogLibraryList/DatabaseItem/index.tsx +++ b/ui/src/pages/DataLogs/components/DataSourceMenu/LogLibraryList/DatabaseItem/index.tsx @@ -130,7 +130,11 @@ const DatabaseItem = (props: { databasesItem: any; onGetList: any }) => { ); - + let nameDesc = databasesItem.databaseName; + if (databasesItem.desc) { + // 只取desc前7个字符 + nameDesc += " (" + databasesItem.desc.substring(0, 7) + ")"; + } return ( { }} > - {databasesItem.databaseName} + {nameDesc} diff --git a/ui/src/pages/DataLogs/components/DataSourceMenu/LogLibraryList/InstanceItem/index.tsx b/ui/src/pages/DataLogs/components/DataSourceMenu/LogLibraryList/InstanceItem/index.tsx index 384852bde..a019bfc3e 100644 --- a/ui/src/pages/DataLogs/components/DataSourceMenu/LogLibraryList/InstanceItem/index.tsx +++ b/ui/src/pages/DataLogs/components/DataSourceMenu/LogLibraryList/InstanceItem/index.tsx @@ -59,6 +59,11 @@ const InstanceItem = (props: { instanceItem: any }) => { }, ]; + let nameDesc = instanceItem.instanceName; + if (instanceItem.desc) { + // 只取desc前7个字符 + nameDesc += " (" + instanceItem.desc.substring(0, 7) + ")"; + } return ( { }} > - {instanceItem.instanceName} {instanceItem.desc} + {nameDesc}