Skip to content
This repository has been archived by the owner on Sep 15, 2023. It is now read-only.

Commit

Permalink
gorm and redis trace
Browse files Browse the repository at this point in the history
  • Loading branch information
askuy committed Jul 28, 2021
1 parent 88f3faf commit 889cbf3
Show file tree
Hide file tree
Showing 12 changed files with 185 additions and 13 deletions.
11 changes: 11 additions & 0 deletions egorm/examples/grpcmysqltrace/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
run-client:export EGO_DEBUG=true
run-client:export EGO_LOG_EXTRA_KEYS=X-Ego-Uid
run-client:
go run client/main.go --config=client/config.toml


run-server:export EGO_DEBUG=true
run-server:export EGO_LOG_EXTRA_KEYS=X-Ego-Uid
run-server:
go run server/main.go --config=server/config.toml

10 changes: 10 additions & 0 deletions egorm/examples/grpcmysqltrace/client/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[trace.jaeger]

[grpc.test]
debug = true # 开启后并加上export EGO_DEBUG=true,可以看到每次grpc请求,配置名、地址、耗时、请求数据、响应数据
addr = "127.0.0.1:9002"
enableAccessInterceptor = true
enableAccessInterceptorReq = true
enableAccessInterceptorRes = true


55 changes: 55 additions & 0 deletions egorm/examples/grpcmysqltrace/client/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package main

import (
"net/http"

"github.com/davecgh/go-spew/spew"
"github.com/gotomicro/ego/core/transport"
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"

"github.com/gotomicro/ego"
"github.com/gotomicro/ego/client/egrpc"
"github.com/gotomicro/ego/core/elog"
"github.com/gotomicro/ego/examples/helloworld"
)

func main() {
if err := ego.New().Invoker(
invokerGrpc,
callGrpc,
).Run(); err != nil {
elog.Error("startup", elog.FieldErr(err))
}
}

var grpcComp helloworld.GreeterClient

func invokerGrpc() error {
grpcConn := egrpc.Load("grpc.test").Build()
grpcComp = helloworld.NewGreeterClient(grpcConn.ClientConn)
return nil
}

func callGrpc() error {
req := http.Request{}
parentContext := transport.WithValue(req.Context(), "X-Ego-Uid", 9527)
var headers metadata.MD
var trailers metadata.MD
_, err := grpcComp.SayHello(parentContext, &helloworld.HelloRequest{
Name: "i am client",
}, grpc.Header(&headers), grpc.Trailer(&trailers))
if err != nil {
return err
}

spew.Dump(headers)
spew.Dump(trailers)
_, err = grpcComp.SayHello(parentContext, &helloworld.HelloRequest{
Name: "error",
})
if err != nil {
return err
}
return nil
}
18 changes: 18 additions & 0 deletions egorm/examples/grpcmysqltrace/server/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[mysql.test]
# debug = true # ego重写gorm debug,打开后可以看到,配置名、地址、耗时、请求数据、响应数据
# rawDebug = true 原生gorm debug
dsn = "root:root@tcp(127.0.0.1:3306)/test?charset=utf8&parseTime=True&loc=Local&readTimeout=1s&timeout=1s&writeTimeout=3s"
onFail = "panic" # 失败后,直接fail fast,panic操作
# connMaxLifetime = "300s"
# maxIdleConns = 50
# maxOpenConns = 100
# disableTrace = false
# disableMetric = false
enableDetailSQL = true
enableAccessInterceptor = true
enableAccessInterceptorReq = true
enableAccessInterceptorRes = true
[server.grpc]
port = 9002
enableAccessInterceptorReq = true
enableAccessInterceptorRes = true
57 changes: 57 additions & 0 deletions egorm/examples/grpcmysqltrace/server/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package main

import (
"context"
"fmt"

"github.com/gotomicro/ego"
"github.com/gotomicro/ego-component/egorm"
"github.com/gotomicro/ego/core/elog"
"github.com/gotomicro/ego/examples/helloworld"
"github.com/gotomicro/ego/server"
"github.com/gotomicro/ego/server/egrpc"
"gorm.io/gorm"
)

var db *gorm.DB

type User struct {
Id int `gorm:"not null" json:"id"`
Nickname string `gorm:"not null" json:"name"`
}

func (User) TableName() string {
return "user"
}

// export EGO_DEBUG=true && go run main.go --config=config.toml
func main() {
if err := ego.New().Invoker(func() error {
db = egorm.Load("mysql.test").Build()
return nil
}).Serve(func() server.Server {
server := egrpc.Load("server.grpc").Build()
helloworld.RegisterGreeterServer(server.Server, &Greeter{server: server})
return server
}()).Run(); err != nil {
elog.Panic("startup", elog.FieldErr(err))
}
}

// Greeter ...
type Greeter struct {
server *egrpc.Component
helloworld.UnimplementedGreeterServer
}

// SayHello ...
func (g Greeter) SayHello(ctx context.Context, request *helloworld.HelloRequest) (*helloworld.HelloReply, error) {
var user User
err := db.WithContext(ctx).Where("id = ?", 100).First(&user).Error
if err != nil {
return nil, fmt.Errorf("sql err: %w", err)
}
return &helloworld.HelloReply{
Message: "Hello EGO, I'm " + g.server.Address(),
}, nil
}
6 changes: 3 additions & 3 deletions egorm/examples/mysqltrace/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"context"

"github.com/gotomicro/ego"
"github.com/gotomicro/ego/core/elog"

"github.com/gotomicro/ego-component/egorm"
"github.com/gotomicro/ego/core/elog"
"github.com/gotomicro/ego/core/transport"
)

// 1.新建一个数据库叫test
Expand Down Expand Up @@ -56,7 +56,7 @@ func testDB() error {
var user User
for _, db := range DBs {
ctx := context.Background()
ctx = context.WithValue(ctx, "X-Ego-Uid", 9527)
ctx = transport.WithValue(ctx, "X-Ego-Uid", 9527)
err := db.WithContext(ctx).Where("id = ?", 100).First(&user).Error
elog.Info("user info", elog.String("name", user.Nickname), elog.FieldErr(err))
}
Expand Down
4 changes: 3 additions & 1 deletion egorm/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ module github.com/gotomicro/ego-component/egorm
go 1.15

require (
github.com/gotomicro/ego v0.6.1-0.20210727151233-43108b5f6646
github.com/davecgh/go-spew v1.1.1
github.com/gotomicro/ego v0.6.1
github.com/json-iterator/go v1.1.11
github.com/opentracing/opentracing-go v1.1.0
github.com/spf13/cast v1.3.1
github.com/stretchr/testify v1.7.0
google.golang.org/grpc v1.39.0
gorm.io/driver/mysql v1.0.5
gorm.io/driver/postgres v1.0.8
gorm.io/gorm v1.21.3
Expand Down
15 changes: 13 additions & 2 deletions egorm/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym
github.com/HdrHistogram/hdrhistogram-go v1.1.0 h1:6dpdDPTRoo78HxAJ6T1HfMiKSnqhgRRqzCuPshRkQ7I=
github.com/HdrHistogram/hdrhistogram-go v1.1.0/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo=
github.com/RaMin0/gin-health-check v0.0.0-20180807004848-a677317b3f01/go.mod h1:vZ/F780spvlix7Qg0/17Uj0SayI+CqtybQHtPEV9RTE=
github.com/StackExchange/wmi v0.0.0-20210224194228-fe8f1750fd46 h1:5sXbqlSomvdjlRbWyNqkPsJ3Fg+tQZCbgeX1VGljbQY=
github.com/StackExchange/wmi v0.0.0-20210224194228-fe8f1750fd46/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
Expand Down Expand Up @@ -55,6 +56,7 @@ github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vb
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
github.com/go-ole/go-ole v1.2.5 h1:t4MGB5xEDZvXI+0rMjjsfBsD7yAgp/s9ZDkL1JndXwY=
github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
Expand Down Expand Up @@ -97,8 +99,12 @@ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gotomicro/ego v0.6.1-0.20210727151233-43108b5f6646 h1:FkddZJKNm6kAqh73cR2dgR0qkR7EY5HAyTl1jCRDtW0=
github.com/gotomicro/ego v0.6.1-0.20210727151233-43108b5f6646/go.mod h1:srmc4FufkH/1JHGgcc1XaDWZQKyRS/OV86x5hZQ4Lsc=
github.com/gotomicro/ego v0.6.1-0.20210728093546-31a8a66c0ad3 h1:/F+qbyY6+kJEa/i4H4ZPsYdT6eD7M6v0bcLzhdUzfYQ=
github.com/gotomicro/ego v0.6.1-0.20210728093546-31a8a66c0ad3/go.mod h1:srmc4FufkH/1JHGgcc1XaDWZQKyRS/OV86x5hZQ4Lsc=
github.com/gotomicro/ego v0.6.1-0.20210728143206-0199026b27e5 h1:79RwagolHQPutBZU87xCGzX89Q7K/H5shbN3VwLQGPE=
github.com/gotomicro/ego v0.6.1-0.20210728143206-0199026b27e5/go.mod h1:srmc4FufkH/1JHGgcc1XaDWZQKyRS/OV86x5hZQ4Lsc=
github.com/gotomicro/ego v0.6.1 h1:YWDTlxDcsDMhZRr4aN99sBgqqd55XgsHkSNTUWA/nio=
github.com/gotomicro/ego v0.6.1/go.mod h1:srmc4FufkH/1JHGgcc1XaDWZQKyRS/OV86x5hZQ4Lsc=
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/jackc/chunkreader v1.0.0 h1:4s39bBR8ByfqH+DKm8rQA3E1LHZWB9XWcrz8fqaZbe0=
github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo=
Expand Down Expand Up @@ -239,6 +245,7 @@ github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU=
github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/shirou/gopsutil v3.21.3+incompatible h1:uenXGGa8ESCQq+dbgtl916dmg6PSAz2cXov0uORQ9v8=
github.com/shirou/gopsutil v3.21.3+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
github.com/shopspring/decimal v0.0.0-20200227202807-02e2044944cc h1:jUIKcSPO9MoMJBbEoyE/RJoE8vz7Mb8AjvifMMwSyvY=
Expand All @@ -258,7 +265,9 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/tklauser/go-sysconf v0.3.6 h1:oc1sJWvKkmvIxhDHeKWvZS4f6AW+YcoguSfRF2/Hmo4=
github.com/tklauser/go-sysconf v0.3.6/go.mod h1:MkWzOF4RMCshBAMXuhXJs64Rte09mITnppBXY/rYEFI=
github.com/tklauser/numcpus v0.2.2 h1:oyhllyrScuYI6g+h/zUvNXNp1wy7x8qQy3t/piefldA=
github.com/tklauser/numcpus v0.2.2/go.mod h1:x3qojaO3uyYt0i56EW/VUYs7uBvdl2fkfZFu0T9wgjM=
github.com/uber/jaeger-client-go v2.23.1+incompatible h1:uArBYHQR0HqLFFAypI7RsWTzPSj/bDpmZZuQjMLSg1A=
github.com/uber/jaeger-client-go v2.23.1+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk=
Expand Down Expand Up @@ -328,6 +337,7 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand Down Expand Up @@ -408,6 +418,7 @@ google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoA
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
google.golang.org/genproto v0.0.0-20210708141623-e76da96a951f h1:khwpF3oSk7GIab/7DDMDyE8cPQEO6FAfOcWHIRAhO20=
google.golang.org/genproto v0.0.0-20210708141623-e76da96a951f/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
Expand Down
10 changes: 7 additions & 3 deletions egorm/interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"time"

"github.com/gotomicro/ego-component/egorm/dsn"
"github.com/gotomicro/ego/core/transport"
"github.com/spf13/cast"

"github.com/gotomicro/ego/core/eapp"
Expand Down Expand Up @@ -61,7 +62,10 @@ func metricInterceptor(compName string, dsn *dsn.DSN, op string, config *config,
beg := time.Now()
next(db)
cost := time.Since(beg)
var fields = make([]elog.Field, 0, 15)

loggerKeys := transport.CustomContextKeys()

var fields = make([]elog.Field, 0, 15+len(loggerKeys))
fields = append(fields, elog.FieldMethod(op), elog.FieldName(dsn.DBName+"."+db.Statement.Table), elog.FieldCost(cost))
if config.EnableAccessInterceptorReq {
fields = append(fields, elog.String("req", logSQL(db.Statement.SQL.String(), db.Statement.Vars, config.EnableDetailSQL)))
Expand All @@ -76,7 +80,7 @@ func metricInterceptor(compName string, dsn *dsn.DSN, op string, config *config,
}

// 支持自定义log
for _, key := range eapp.EgoLogExtraKeys() {
for _, key := range loggerKeys {
if value := getContextValue(db.Statement.Context, key); value != "" {
fields = append(fields, elog.FieldCustomKeyValue(key, value))
}
Expand Down Expand Up @@ -158,5 +162,5 @@ func getContextValue(c context.Context, key string) string {
if key == "" {
return ""
}
return cast.ToString(c.Value(key))
return cast.ToString(transport.Value(c, key))
}
2 changes: 1 addition & 1 deletion eredis/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.15
require (
github.com/BurntSushi/toml v0.3.1
github.com/go-redis/redis/v8 v8.8.1-0.20210327152210-1e30221353c4
github.com/gotomicro/ego v0.6.1-0.20210727151233-43108b5f6646
github.com/gotomicro/ego v0.6.1
github.com/opentracing/opentracing-go v1.1.0
github.com/spf13/cast v1.3.1 // indirect
github.com/stretchr/testify v1.7.0
Expand Down
2 changes: 2 additions & 0 deletions eredis/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gotomicro/ego v0.6.1-0.20210727151233-43108b5f6646 h1:FkddZJKNm6kAqh73cR2dgR0qkR7EY5HAyTl1jCRDtW0=
github.com/gotomicro/ego v0.6.1-0.20210727151233-43108b5f6646/go.mod h1:srmc4FufkH/1JHGgcc1XaDWZQKyRS/OV86x5hZQ4Lsc=
github.com/gotomicro/ego v0.6.1 h1:YWDTlxDcsDMhZRr4aN99sBgqqd55XgsHkSNTUWA/nio=
github.com/gotomicro/ego v0.6.1/go.mod h1:srmc4FufkH/1JHGgcc1XaDWZQKyRS/OV86x5hZQ4Lsc=
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
Expand Down
8 changes: 5 additions & 3 deletions eredis/interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/gotomicro/ego/core/elog"
"github.com/gotomicro/ego/core/emetric"
"github.com/gotomicro/ego/core/etrace"
"github.com/gotomicro/ego/core/transport"
"github.com/gotomicro/ego/core/util/xdebug"
"github.com/opentracing/opentracing-go"
"github.com/spf13/cast"
Expand Down Expand Up @@ -141,7 +142,8 @@ func metricInterceptor(compName string, config *config, logger *elog.Component)
func accessInterceptor(compName string, config *config, logger *elog.Component) *interceptor {
return newInterceptor(compName, config, logger).setAfterProcess(
func(ctx context.Context, cmd redis.Cmder) error {
var fields = make([]elog.Field, 0, 15)
loggerKeys := transport.CustomContextKeys()
var fields = make([]elog.Field, 0, 15+len(loggerKeys))
var err = cmd.Err()
cost := time.Since(ctx.Value(ctxBegKey).(time.Time))
fields = append(fields, elog.FieldComponentName(compName), elog.FieldMethod(cmd.Name()), elog.FieldCost(cost))
Expand All @@ -159,7 +161,7 @@ func accessInterceptor(compName string, config *config, logger *elog.Component)
}

// 支持自定义log
for _, key := range eapp.EgoLogExtraKeys() {
for _, key := range loggerKeys {
if value := getContextValue(ctx, key); value != "" {
fields = append(fields, elog.FieldCustomKeyValue(key, value))
}
Expand Down Expand Up @@ -216,5 +218,5 @@ func getContextValue(c context.Context, key string) string {
if key == "" {
return ""
}
return cast.ToString(c.Value(key))
return cast.ToString(transport.Value(c, key))
}

0 comments on commit 889cbf3

Please sign in to comment.