Compare commits

..

No commits in common. "c9ca2b38587148986fbda16f83c5a4b915507313" and "0ed7416b49d81506087d8f08a8b3d05cba30c5d8" have entirely different histories.

View File

@ -10,6 +10,7 @@ import (
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"go.uber.org/zap" "go.uber.org/zap"
"go.uber.org/zap/zapcore" "go.uber.org/zap/zapcore"
"sync"
"time" "time"
) )
@ -76,7 +77,10 @@ func (c lokiWriter) Write(p []byte) (int, error) {
label["caller"] = model.LabelValue(li.Caller) label["caller"] = model.LabelValue(li.Caller)
// 异步推送消息到服务器 // 异步推送消息到服务器
var wg sync.WaitGroup
wg.Add(1)
_ = ants.Submit(func() { _ = ants.Submit(func() {
defer wg.Done()
t, e := time.ParseInLocation("2006-01-02 15:04:05.000", li.Ts, time.Local) t, e := time.ParseInLocation("2006-01-02 15:04:05.000", li.Ts, time.Local)
if e != nil { if e != nil {
t = time.Now().Local() t = time.Now().Local()
@ -85,8 +89,7 @@ func (c lokiWriter) Write(p []byte) (int, error) {
fmt.Printf("日志推送到Loki失败: %v\n", err.Error()) fmt.Printf("日志推送到Loki失败: %v\n", err.Error())
} }
}) })
wg.Wait()
defer ants.Release()
return 0, nil return 0, nil
} }