From be13f6548c11b8def18bf533caf3fb485cd41525 Mon Sep 17 00:00:00 2001 From: steden <1470804@qq.com> Date: Wed, 20 Nov 2024 20:26:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8sonic=E4=BB=A3=E6=9B=BF?= =?UTF-8?q?=E5=8E=9F=E7=94=9Fjson?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 8 ++++++++ saveTraceContextConsumer.go | 7 ++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 0aac0c6..72a1594 100644 --- a/go.mod +++ b/go.mod @@ -5,12 +5,20 @@ go 1.21 toolchain go1.23.3 require ( + github.com/bytedance/sonic v1.12.4 github.com/farseer-go/collections v0.15.0 github.com/farseer-go/fs v0.15.0 github.com/farseer-go/queue v0.15.0 ) require ( + github.com/bytedance/sonic/loader v0.2.1 // indirect + github.com/cloudwego/base64x v0.1.4 // indirect + github.com/cloudwego/iasm v0.2.0 // indirect + github.com/klauspost/cpuid/v2 v2.2.9 // indirect github.com/timandy/routine v1.1.4 // indirect + github.com/twitchyliquid64/golang-asm v0.15.1 // indirect + golang.org/x/arch v0.12.0 // indirect + golang.org/x/sys v0.27.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/saveTraceContextConsumer.go b/saveTraceContextConsumer.go index 9b0a5ca..5ed6d95 100644 --- a/saveTraceContextConsumer.go +++ b/saveTraceContextConsumer.go @@ -3,8 +3,10 @@ package linkTrace import ( "bytes" "crypto/tls" - "encoding/json" "fmt" + "net/http" + + "github.com/bytedance/sonic" "github.com/farseer-go/collections" "github.com/farseer-go/fs/configure" "github.com/farseer-go/fs/container" @@ -13,7 +15,6 @@ import ( "github.com/farseer-go/fs/parse" "github.com/farseer-go/fs/trace" "github.com/farseer-go/linkTrace/eumTraceType" - "net/http" ) // FopsServer fops地址 @@ -44,7 +45,7 @@ type UploadTraceRequest struct { // UploadTrace 上传链路记录 func uploadTrace(lstTraceContext any) error { - bodyByte, _ := json.Marshal(UploadTraceRequest{List: lstTraceContext}) + bodyByte, _ := sonic.Marshal(UploadTraceRequest{List: lstTraceContext}) url := configure.GetFopsServer() + "linkTrace/upload" newRequest, _ := http.NewRequest("POST", url, bytes.NewReader(bodyByte)) newRequest.Header.Set("Content-Type", "application/json")