From 0cf7f952e2e0ea73352215aa8accd298f3688822 Mon Sep 17 00:00:00 2001 From: Liujian <824010343@qq.com> Date: Wed, 30 Apr 2025 15:52:48 +0800 Subject: [PATCH] update service logs --- go.mod | 2 +- go.sum | 4 ++-- module/service/iml.go | 20 +++++++++++++++++--- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index c54a7894..95c0a6af 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ toolchain go1.23.6 require ( github.com/eolinker/ap-account v1.0.15 github.com/eolinker/eosc v0.18.3 - github.com/eolinker/go-common v1.1.6 + github.com/eolinker/go-common v1.1.7 github.com/gabriel-vasile/mimetype v1.4.4 github.com/getkin/kin-openapi v0.127.0 github.com/gin-contrib/gzip v1.0.1 diff --git a/go.sum b/go.sum index 7cf5d0f2..42d19a99 100644 --- a/go.sum +++ b/go.sum @@ -32,8 +32,8 @@ github.com/eolinker/ap-account v1.0.15 h1:n6DJeL6RHZ8eLlZUcY2U3H4d/GPaA5oelAx3R0 github.com/eolinker/ap-account v1.0.15/go.mod h1:zm/Ivs6waJ/M/nEszhpPmM6g50y/MKO+5eABFAdeD0g= github.com/eolinker/eosc v0.18.3 h1:3IK5HkAPnJRfLbQ0FR7kWsZr6Y/OiqqGazvN1q2BL5A= github.com/eolinker/eosc v0.18.3/go.mod h1:O9PQQXFCpB6fjHf+oFt/LN6EOAv779ItbMixMKCfTfk= -github.com/eolinker/go-common v1.1.6 h1:s+NaQL0InjX/MwWY53+8y8qzAgsULIUc4U6nWXWQ2Nw= -github.com/eolinker/go-common v1.1.6/go.mod h1:Kb/jENMN1mApnodvRgV4YwO9FJby1Jkt2EUjrBjvSX4= +github.com/eolinker/go-common v1.1.7 h1:bi7wDmlCYQGjS3k8Bz/o+Mo9aMJAzmPsBLXWurxPfwk= +github.com/eolinker/go-common v1.1.7/go.mod h1:Kb/jENMN1mApnodvRgV4YwO9FJby1Jkt2EUjrBjvSX4= github.com/gabriel-vasile/mimetype v1.4.4 h1:QjV6pZ7/XZ7ryI2KuyeEDE8wnh7fHP9YnQy+R0LnH8I= github.com/gabriel-vasile/mimetype v1.4.4/go.mod h1:JwLei5XPtWdGiMFB5Pjle1oEeoSeEuJfJE+TtfvdB/s= github.com/getkin/kin-openapi v0.127.0 h1:Mghqi3Dhryf3F8vR370nN67pAERW+3a95vomb3MAREY= diff --git a/module/service/iml.go b/module/service/iml.go index 3028c19f..4e783150 100644 --- a/module/service/iml.go +++ b/module/service/iml.go @@ -211,7 +211,7 @@ func (i *imlServiceModule) RestLogs(ctx context.Context, serviceId string, start return nil, 0, err } return utils.SliceToSlice(list, func(s *log_service.Item) *service_dto.RestLogItem { - return &service_dto.RestLogItem{ + item := &service_dto.RestLogItem{ Id: s.ID, API: auto.UUID(s.API), Status: s.StatusCode, @@ -221,6 +221,13 @@ func (i *imlServiceModule) RestLogs(ctx context.Context, serviceId string, start ResponseTime: common.FormatTime(s.ResponseTime), Traffic: common.FormatByte(s.Traffic), } + if s.Consumer == "apipark-global" { + item.Consumer = auto.Label{ + Id: s.Consumer, + Name: "System Consumer", + } + } + return item }), total, nil } @@ -230,18 +237,25 @@ func (i *imlServiceModule) AILogs(ctx context.Context, serviceId string, start i return nil, 0, err } return utils.SliceToSlice(list, func(s *log_service.Item) *service_dto.AILogItem { - return &service_dto.AILogItem{ + item := &service_dto.AILogItem{ Id: s.ID, API: auto.UUID(s.API), Status: s.StatusCode, LogTime: auto.TimeLabel(s.RecordTime), Ip: s.RemoteIP, Token: s.TotalToken, - TokenPerSecond: s.TotalToken / s.ResponseTime, + TokenPerSecond: s.TotalToken * 1000 / s.ResponseTime, Consumer: auto.UUID(s.Consumer), Provider: auto.UUID(s.AIProvider), Model: s.AIModel, } + if s.Consumer == "apipark-global" { + item.Consumer = auto.Label{ + Id: s.Consumer, + Name: "System Consumer", + } + } + return item }), total, nil }