Skip to content

Commit

Permalink
使用sonic代替原生json
Browse files Browse the repository at this point in the history
  • Loading branch information
steden committed Nov 20, 2024
1 parent ac44b06 commit be13f65
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
8 changes: 8 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
7 changes: 4 additions & 3 deletions saveTraceContextConsumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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地址
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit be13f65

Please sign in to comment.