From 9459a98224aca6bc5ef15878342536eaffc20e59 Mon Sep 17 00:00:00 2001 From: AI Engineer Date: Sun, 10 May 2026 10:50:00 +0800 Subject: [PATCH] feat: align GetDefaultName with service SOP (by AI) --- logger.go | 2 +- utility.go | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/logger.go b/logger.go index 7502a14..9b20b17 100644 --- a/logger.go +++ b/logger.go @@ -48,7 +48,7 @@ func NewLogger(conf Config) *Logger { logger := Logger{ truncations: cast.Split(conf.Truncations, ","), - traceId: id.MakeID(10), + traceId: id.Get10Bytes14MPerSecond(), } if len(conf.Sensitive) > 0 { diff --git a/utility.go b/utility.go index c7e119a..9d25986 100644 --- a/utility.go +++ b/utility.go @@ -194,17 +194,14 @@ func getCallStacks(truncations []string) []string { // GetDefaultName 获取默认应用名称 func GetDefaultName() string { - name := os.Getenv("DISCOVER_APP") - if name == "" { - name = os.Getenv("discover_app") - } - if name == "" { - if info, ok := debug.ReadBuildInfo(); ok && info.Path != "" && info.Path != "command-line-arguments" { - name = path.Base(info.Path) - } + name := "" + if info, ok := debug.ReadBuildInfo(); ok && info.Path != "" && info.Path != "command-line-arguments" { + name = path.Base(info.Path) } if name == "" { name = path.Base(os.Args[0]) } + // 处理 Windows 下的 .exe 后缀 + name = strings.TrimSuffix(name, ".exe") return name }