From 869dedc580e13ccf2afe528759e2df39772eed1f Mon Sep 17 00:00:00 2001 From: coward Date: Fri, 29 Nov 2024 10:32:57 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=E4=BF=AE=E5=A4=8Dloki=E5=BC=82=E6=AD=A5?= =?UTF-8?q?=E6=8E=A8=E9=80=81=E6=90=9E=E9=94=99=E4=BA=86=EF=BC=8C=E5=BC=84?= =?UTF-8?q?=E6=88=90=E5=90=8C=E6=AD=A5=E4=BA=86.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- loki.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/loki.go b/loki.go index 01d68b5..27c7bce 100644 --- a/loki.go +++ b/loki.go @@ -10,7 +10,6 @@ import ( "github.com/prometheus/common/model" "go.uber.org/zap" "go.uber.org/zap/zapcore" - "sync" "time" ) @@ -77,10 +76,7 @@ func (c lokiWriter) Write(p []byte) (int, error) { label["caller"] = model.LabelValue(li.Caller) // 异步推送消息到服务器 - var wg sync.WaitGroup - wg.Add(1) _ = ants.Submit(func() { - defer wg.Done() t, e := time.ParseInLocation("2006-01-02 15:04:05.000", li.Ts, time.Local) if e != nil { t = time.Now().Local() @@ -89,7 +85,8 @@ func (c lokiWriter) Write(p []byte) (int, error) { fmt.Printf("日志推送到Loki失败: %v\n", err.Error()) } }) - wg.Wait() + + defer ants.Release() return 0, nil }