diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..e106be0 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,42 @@ +*.o +*.a +*.so +_obj +_test +*.[568vq] +[568vq].out +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* +_testmain.go +*.exe +*.exe~ +*.test +*.prof +*.rar +*.zip +*.gz +*.psd +*.bmd +*.cfg +*.pptx +*.log +*nohup.out +*settings.pyc +*.sublime-project +*.sublime-workspace +!.gitkeep +.DS_Store +/.idea +/.vscode +#/output +*.local.yml +dumped_hertz_remote_config.json + +/data +hz_update.sh +kitex_update.sh +/codeql +analz.sarif \ No newline at end of file diff --git a/.gitignore b/.gitignore index caa3b6a..054160f 100755 --- a/.gitignore +++ b/.gitignore @@ -34,7 +34,7 @@ _testmain.go /output *.local.yml dumped_hertz_remote_config.json - +/cmd/*/output /data hz_update.sh kitex_update.sh diff --git a/Dockerfile b/Dockerfile index b86f8e7..9683396 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:latest AS builder +FROM golang:1.22 AS builder LABEL authors="fanr" ENV TZ Asia/Shanghai @@ -12,5 +12,6 @@ WORKDIR /app ADD . /app RUN go mod tidy +#CMD ["go run","example"] RUN make build-all diff --git a/Makefile b/Makefile index ee26585..eba5b1d 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ API_PATH= $(DIR)/cmd/api SHELL=/bin/bash KITEX_GEN_PATH=$(DIR)/kitex_gen MODULE= bibi +OUTPUT=$(DIR)/output .PHONY: init init: @@ -28,10 +29,19 @@ $(SERVICES): -.PHONY: build-all -build-all: +.PHONY: start-all +start-all: sh start.sh +SERVICES := api user video interaction follow chat +.PHONY: build-all +build-all: + @for service in $(SERVICES); do \ + cd ${RPC};cd $$service; \ + echo "build $$service ..." && sh build.sh; \ + cd ${RPC}/$$service/output/bin/ && cp -r . ${OUTPUT}/$$service; \ + echo "done"; \ + done \ KSERVICES := user video interaction follow chat .PHONY: kgen diff --git a/causal.md b/causal.md deleted file mode 100644 index ef8e386..0000000 --- a/causal.md +++ /dev/null @@ -1,3 +0,0 @@ -MySQL: -* MySQL的安全性: -`Session`, `WithContext`, `Debug` methods return a `*gorm.DB` instance marked as safe for reuse. They base a newly initialized `*gorm.Statement` on the current conditions. \ No newline at end of file diff --git a/cmd/api/biz/handler/api/chat_handler.go b/cmd/api/biz/handler/api/chat_handler.go index 74316ff..4ba1a77 100644 --- a/cmd/api/biz/handler/api/chat_handler.go +++ b/cmd/api/biz/handler/api/chat_handler.go @@ -8,6 +8,7 @@ import ( "bibi/kitex_gen/chat" "bibi/pkg/errno" "bibi/pkg/pack" + "context" "github.com/cloudwego/kitex/pkg/klog" "github.com/hertz-contrib/websocket" diff --git a/cmd/api/biz/handler/api/user_handler.go b/cmd/api/biz/handler/api/user_handler.go index bef5537..326e629 100644 --- a/cmd/api/biz/handler/api/user_handler.go +++ b/cmd/api/biz/handler/api/user_handler.go @@ -4,9 +4,11 @@ package api import ( "bibi/cmd/api/biz/rpc" - "bibi/kitex_gen/user" "bibi/pkg/errno" "bibi/pkg/pack" + + "bibi/kitex_gen/user" + "context" "path/filepath" @@ -101,7 +103,9 @@ func Info(ctx context.Context, c *app.RequestContext) { resp := new(api.InfoResponse) - rpcResp, err := rpc.UserInfo(ctx, &user.InfoRequest{}) + rpcResp, err := rpc.UserInfo(ctx, &user.InfoRequest{ + req.UserID, + }) if err != nil { pack.SendRPCFailResp(c, err) return diff --git a/cmd/api/biz/mw/jwt/jwt.go b/cmd/api/biz/mw/jwt/jwt.go index b8d975a..be828ba 100644 --- a/cmd/api/biz/mw/jwt/jwt.go +++ b/cmd/api/biz/mw/jwt/jwt.go @@ -4,10 +4,12 @@ import ( "bibi/cmd/api/biz/model/api" "bibi/cmd/api/biz/rpc" "bibi/config" - "bibi/kitex_gen/base" - "bibi/kitex_gen/user" "bibi/pkg/errno" "bibi/pkg/pack" + + "bibi/kitex_gen/base" + "bibi/kitex_gen/user" + "context" "github.com/cloudwego/hertz/pkg/app" "github.com/cloudwego/hertz/pkg/common/hlog" diff --git a/cmd/api/biz/rpc/chat.go b/cmd/api/biz/rpc/chat.go index 4bdc470..a4e724b 100644 --- a/cmd/api/biz/rpc/chat.go +++ b/cmd/api/biz/rpc/chat.go @@ -5,6 +5,8 @@ import ( "bibi/kitex_gen/chat" "bibi/kitex_gen/chat/chathandler" "bibi/pkg/constants" + opentracing "github.com/kitex-contrib/tracer-opentracing" + "context" "github.com/cloudwego/kitex/client" "github.com/cloudwego/kitex/pkg/loadbalance" @@ -26,6 +28,7 @@ func InitChatRPC() { client.WithConnectTimeout(constants.ConnectTimeout), client.WithFailureRetry(retry.NewFailurePolicy()), client.WithResolver(r), + client.WithSuite(opentracing.NewDefaultClientSuite()), client.WithLoadBalancer(loadbalance.NewWeightedRoundRobinBalancer()), ) diff --git a/cmd/api/biz/rpc/follow.go b/cmd/api/biz/rpc/follow.go index 7a259e0..192ad7f 100644 --- a/cmd/api/biz/rpc/follow.go +++ b/cmd/api/biz/rpc/follow.go @@ -10,6 +10,7 @@ import ( "github.com/cloudwego/kitex/pkg/loadbalance" "github.com/cloudwego/kitex/pkg/retry" etcd "github.com/kitex-contrib/registry-etcd" + opentracing "github.com/kitex-contrib/tracer-opentracing" ) func InitFollowRPC() { @@ -26,6 +27,7 @@ func InitFollowRPC() { client.WithConnectTimeout(constants.ConnectTimeout), client.WithFailureRetry(retry.NewFailurePolicy()), client.WithResolver(r), + client.WithSuite(opentracing.NewDefaultClientSuite()), client.WithLoadBalancer(loadbalance.NewWeightedRoundRobinBalancer()), ) diff --git a/cmd/api/biz/rpc/init.go b/cmd/api/biz/rpc/init.go index 2a5f1e5..695c9cc 100644 --- a/cmd/api/biz/rpc/init.go +++ b/cmd/api/biz/rpc/init.go @@ -22,5 +22,4 @@ func Init() { InitFollowRPC() InitInteractionRPC() InitChatRPC() - } diff --git a/cmd/api/biz/rpc/interaction.go b/cmd/api/biz/rpc/interaction.go index 797a586..321fcea 100644 --- a/cmd/api/biz/rpc/interaction.go +++ b/cmd/api/biz/rpc/interaction.go @@ -5,6 +5,7 @@ import ( "bibi/kitex_gen/interaction" "bibi/kitex_gen/interaction/interactionhandler" "context" + opentracing "github.com/kitex-contrib/tracer-opentracing" "bibi/pkg/constants" "github.com/cloudwego/kitex/client" @@ -27,6 +28,7 @@ func InitInteractionRPC() { client.WithConnectTimeout(constants.ConnectTimeout), client.WithFailureRetry(retry.NewFailurePolicy()), client.WithResolver(r), + client.WithSuite(opentracing.NewDefaultClientSuite()), client.WithLoadBalancer(loadbalance.NewWeightedRoundRobinBalancer()), ) diff --git a/cmd/api/biz/rpc/user.go b/cmd/api/biz/rpc/user.go index 8df8c5c..6e5118d 100644 --- a/cmd/api/biz/rpc/user.go +++ b/cmd/api/biz/rpc/user.go @@ -10,6 +10,7 @@ import ( "github.com/cloudwego/kitex/pkg/loadbalance" "github.com/cloudwego/kitex/pkg/retry" etcd "github.com/kitex-contrib/registry-etcd" + kopentracing "github.com/kitex-contrib/tracer-opentracing" ) func InitUserRPC() { @@ -19,6 +20,10 @@ func InitUserRPC() { panic(err) } + //kTracer, kCloser := tracer.InitJaegerTracer("kitex-client") + //defer kCloser.Close() + //tracer.InitJaegerTracer("kitex-client") + c, err := userhandler.NewClient( constants.UserServiceName, client.WithMuxConnection(constants.MuxConnection), @@ -26,6 +31,11 @@ func InitUserRPC() { client.WithConnectTimeout(constants.ConnectTimeout), client.WithFailureRetry(retry.NewFailurePolicy()), client.WithResolver(r), + client.WithSuite(kopentracing.NewDefaultClientSuite()), + //client.WithSuite(kopentracing.NewClientSuite(kTracer, func(c context.Context) string { + // endpoint := rpcinfo.GetRPCInfo(c).From() + // return endpoint.ServiceName() + "::" + endpoint.Method() + //})), //jaeger client.WithLoadBalancer(loadbalance.NewWeightedRoundRobinBalancer()), ) diff --git a/cmd/api/biz/rpc/video.go b/cmd/api/biz/rpc/video.go index 16fa531..1552a6b 100644 --- a/cmd/api/biz/rpc/video.go +++ b/cmd/api/biz/rpc/video.go @@ -5,11 +5,13 @@ import ( "bibi/kitex_gen/video" "bibi/kitex_gen/video/videohandler" "bibi/pkg/constants" + "bibi/pkg/tracer" "context" "github.com/cloudwego/kitex/client" "github.com/cloudwego/kitex/pkg/loadbalance" "github.com/cloudwego/kitex/pkg/retry" etcd "github.com/kitex-contrib/registry-etcd" + opentracing "github.com/kitex-contrib/tracer-opentracing" ) func InitVideoRPC() { @@ -19,6 +21,7 @@ func InitVideoRPC() { panic(err) } + tracer.InitJaegerTracer(constants.VideoServiceName) c, err := videohandler.NewClient( constants.VideoServiceName, client.WithMuxConnection(constants.MuxConnection), @@ -26,6 +29,7 @@ func InitVideoRPC() { client.WithConnectTimeout(constants.ConnectTimeout), client.WithFailureRetry(retry.NewFailurePolicy()), client.WithResolver(r), + client.WithSuite(opentracing.NewDefaultClientSuite()), client.WithLoadBalancer(loadbalance.NewWeightedRoundRobinBalancer()), ) diff --git a/cmd/api/main.go b/cmd/api/main.go index b1dfc81..1af621d 100755 --- a/cmd/api/main.go +++ b/cmd/api/main.go @@ -8,9 +8,11 @@ import ( "bibi/cmd/api/biz/ws/monitor" "bibi/config" "bibi/pkg/constants" + "bibi/pkg/tracer" "bibi/pkg/utils" "github.com/cloudwego/hertz/pkg/app/server" "github.com/cloudwego/kitex/pkg/klog" + hertztracer "github.com/hertz-contrib/tracer/hertz" ) var listenAddr string @@ -23,6 +25,9 @@ func Init() { } func main() { Init() + //_, hCloser := tracer.InitApiTracer(constants.APIServiceName) + //defer hCloser.Close() + tracer.InitJaegerTracer(constants.APIServiceName) //获取addr for index, addr := range config.Service.AddrList { @@ -38,8 +43,13 @@ func main() { h := server.New( server.WithHostPorts(listenAddr), server.WithStreamBody(true), + server.WithTracer(hertztracer.NewDefaultTracer()), server.WithMaxRequestBodySize(constants.MaxRequestBodySize), //最大字节数 + //server.WithTracer(hertztracer.NewTracer(hTracer, func(c *app.RequestContext) string { + // return listenAddr + "::" + c.FullPath() + //})), //jaeger ) + h.Use(hertztracer.ServerCtx()) //jaeger //websocket //NoHijackConnPool 将控制是否使用缓存池来获取/释放劫持连接。 diff --git a/cmd/interaction/main.go b/cmd/interaction/main.go index e8c1b16..a674703 100644 --- a/cmd/interaction/main.go +++ b/cmd/interaction/main.go @@ -6,6 +6,7 @@ import ( "bibi/config" interaction "bibi/kitex_gen/interaction/interactionhandler" "bibi/pkg/constants" + "bibi/pkg/tracer" "bibi/pkg/utils" "bibi/pkg/utils/eslogrus" "crypto/tls" @@ -18,6 +19,7 @@ import ( elastic "github.com/elastic/go-elasticsearch/v8" kitexlogrus "github.com/kitex-contrib/obs-opentelemetry/logging/logrus" etcd "github.com/kitex-contrib/registry-etcd" + opentracing "github.com/kitex-contrib/tracer-opentracing" "github.com/sirupsen/logrus" "net" "net/http" @@ -36,7 +38,7 @@ func Init() { InitEs() klog.SetLevel(klog.LevelDebug) klog.SetLogger(kitexlogrus.NewLogger(kitexlogrus.WithHook(EsHookLog()))) - + tracer.InitJaegerTracer(constants.UserServiceName) rpc.InitVideoRPC() } @@ -68,6 +70,7 @@ func main() { svr := interaction.NewServer(interactionHandlerImpl, // 指定 Registry 与服务基本信息 server.WithRegistry(r), + server.WithSuite(opentracing.NewDefaultServerSuite()), server.WithServiceAddr(serviceAddr), server.WithServerBasicInfo( &rpcinfo.EndpointBasicInfo{ diff --git a/cmd/interaction/rpc/video.go b/cmd/interaction/rpc/video.go index ea39c8b..c07ce80 100644 --- a/cmd/interaction/rpc/video.go +++ b/cmd/interaction/rpc/video.go @@ -10,6 +10,7 @@ import ( "github.com/cloudwego/kitex/pkg/loadbalance" "github.com/cloudwego/kitex/pkg/retry" etcd "github.com/kitex-contrib/registry-etcd" + opentracing "github.com/kitex-contrib/tracer-opentracing" ) var videoClient videohandler.Client @@ -28,6 +29,7 @@ func InitVideoRPC() { client.WithConnectTimeout(constants.ConnectTimeout), client.WithFailureRetry(retry.NewFailurePolicy()), client.WithResolver(r), + client.WithSuite(opentracing.NewDefaultClientSuite()), client.WithLoadBalancer(loadbalance.NewWeightedRoundRobinBalancer()), ) diff --git a/cmd/user/handler.go b/cmd/user/handler.go index 221c9da..2bab3fb 100644 --- a/cmd/user/handler.go +++ b/cmd/user/handler.go @@ -44,9 +44,12 @@ func (s *UserHandlerImpl) Register(ctx context.Context, req *user.RegisterReques // Login implements the UserHandlerImpl interface. func (s *UserHandlerImpl) Login(ctx context.Context, req *user.LoginRequest) (resp *user.LoginResponse, err error) { resp = new(user.LoginResponse) - + //stTracer, closer := tracer.InitJaegerTracer("login") + //defer closer.Close() + //parentSpan := stTracer.StartSpan("handler") + //defer parentSpan.Finish() + //userResp, err := service.NewUserService(ctx).Login(req, stTracer, parentSpan) userResp, err := service.NewUserService(ctx).Login(req) - resp.Base = pack.BuildBaseResp(err) if err != nil { return resp, nil diff --git a/cmd/user/main.go b/cmd/user/main.go index 029d3b9..5a970b5 100644 --- a/cmd/user/main.go +++ b/cmd/user/main.go @@ -5,6 +5,7 @@ import ( "bibi/config" user "bibi/kitex_gen/user/userhandler" "bibi/pkg/constants" + "bibi/pkg/tracer" "bibi/pkg/utils" "github.com/cloudwego/kitex/pkg/klog" "github.com/cloudwego/kitex/pkg/limit" @@ -12,19 +13,27 @@ import ( "github.com/cloudwego/kitex/server" "github.com/cloudwego/netpoll" etcd "github.com/kitex-contrib/registry-etcd" + kopentracing "github.com/kitex-contrib/tracer-opentracing" "log" ) var listenAddr string +//var GloTracer opentracing.Tracer + func Init() { config.Init(constants.UserServiceName) dal.Init() - + tracer.InitJaegerTracer(constants.UserServiceName) + //GloTracer = tracer.NewJaegerTracer(constants.UserServiceName, listenAddr) } func main() { Init() + //kTracer, closer := tracer.InitJaegerTracer("kitex-server") + //defer closer.Close() + //opentracing.SetGlobalTracer(kTracer) + //注册到etcd r, err := etcd.NewEtcdRegistry([]string{config.Etcd.Addr}) if err != nil { @@ -57,6 +66,11 @@ func main() { //那Impl携带一个Client就没用了 svr := user.NewServer(userHandlerImpl, // 指定 Registry 与服务基本信息 + server.WithSuite(kopentracing.NewDefaultServerSuite()), //jaeger + //server.WithSuite(kopentracing.NewServerSuite(kTracer, func(c context.Context) string { + // endpoint := rpcinfo.GetRPCInfo(c).From() + // return endpoint.ServiceName() + "::" + endpoint.Method() + //})), server.WithRegistry(r), server.WithServiceAddr(serviceAddr), server.WithServerBasicInfo( diff --git a/cmd/user/service/basic.go b/cmd/user/service/basic.go index f7d542c..fd9e848 100644 --- a/cmd/user/service/basic.go +++ b/cmd/user/service/basic.go @@ -22,18 +22,28 @@ func (s *UserService) Register(req *user.RegisterRequest) (*db.User, error) { return db.Register(s.ctx, userModel) } -func (s *UserService) Login(req *user.LoginRequest) (*db.User, error) { +func (s *UserService) Login(req *user.LoginRequest /*, stTracer opentracing.Tracer, parentSpan opentracing.Span*/) (*db.User, error) { userModel := &db.User{ UserName: req.Username, Password: req.Password, } + //childSpan1 := stTracer.StartSpan( + // "mysql", + // opentracing.ChildOf(parentSpan.Context()), + //) userResp, err := db.Login(s.ctx, userModel) if err != nil { return nil, err } + //childSpan1.Finish() + //childSpan2 := stTracer.StartSpan( + // "otp", + // opentracing.ChildOf(childSpan1.Context()), + //) if userResp.Type2fa == 1 && !otp2fa.CheckTotp(*req.Otp, userResp.Otp) { return nil, errno.Verify2FAError } + //childSpan2.Finish() return userResp, nil } diff --git a/cmd/video/main.go b/cmd/video/main.go index b6dce0f..160894e 100644 --- a/cmd/video/main.go +++ b/cmd/video/main.go @@ -6,6 +6,7 @@ import ( "bibi/config" video "bibi/kitex_gen/video/videohandler" "bibi/pkg/constants" + "bibi/pkg/tracer" "bibi/pkg/utils" "bibi/pkg/utils/eslogrus" "crypto/tls" @@ -18,6 +19,7 @@ import ( elastic "github.com/elastic/go-elasticsearch/v8" kitexlogrus "github.com/kitex-contrib/obs-opentelemetry/logging/logrus" etcd "github.com/kitex-contrib/registry-etcd" + opentracing "github.com/kitex-contrib/tracer-opentracing" "github.com/sirupsen/logrus" "net" "net/http" @@ -36,7 +38,7 @@ func Init() { InitEs() klog.SetLevel(klog.LevelDebug) klog.SetLogger(kitexlogrus.NewLogger(kitexlogrus.WithHook(EsHookLog()))) - + tracer.InitJaegerTracer(constants.VideoServiceName) rpc.InitInteractionRPC() rpc.InitUserRPC() } @@ -66,6 +68,7 @@ func main() { svr := video.NewServer(videoHandlerImpl, server.WithRegistry(r), server.WithServiceAddr(serviceAddr), + server.WithSuite(opentracing.NewDefaultServerSuite()), server.WithServerBasicInfo( &rpcinfo.EndpointBasicInfo{ ServiceName: constants.VideoServiceName, diff --git a/cmd/video/rpc/interaction.go b/cmd/video/rpc/interaction.go index 1bd6a76..5c31d9c 100644 --- a/cmd/video/rpc/interaction.go +++ b/cmd/video/rpc/interaction.go @@ -10,6 +10,7 @@ import ( "github.com/cloudwego/kitex/pkg/loadbalance" "github.com/cloudwego/kitex/pkg/retry" etcd "github.com/kitex-contrib/registry-etcd" + kopentracing "github.com/kitex-contrib/tracer-opentracing" ) var interactionClient interactionhandler.Client @@ -28,6 +29,7 @@ func InitInteractionRPC() { client.WithConnectTimeout(constants.ConnectTimeout), client.WithFailureRetry(retry.NewFailurePolicy()), client.WithResolver(r), + client.WithSuite(kopentracing.NewDefaultClientSuite()), client.WithLoadBalancer(loadbalance.NewWeightedRoundRobinBalancer()), ) diff --git a/cmd/video/rpc/user.go b/cmd/video/rpc/user.go index 0d41edf..5677cc6 100644 --- a/cmd/video/rpc/user.go +++ b/cmd/video/rpc/user.go @@ -10,6 +10,7 @@ import ( "github.com/cloudwego/kitex/pkg/loadbalance" "github.com/cloudwego/kitex/pkg/retry" etcd "github.com/kitex-contrib/registry-etcd" + kopentracing "github.com/kitex-contrib/tracer-opentracing" ) var userClient userhandler.Client @@ -28,6 +29,7 @@ func InitUserRPC() { client.WithConnectTimeout(constants.ConnectTimeout), client.WithFailureRetry(retry.NewFailurePolicy()), client.WithResolver(r), + client.WithSuite(kopentracing.NewDefaultClientSuite()), client.WithLoadBalancer(loadbalance.NewWeightedRoundRobinBalancer()), ) diff --git a/config/config.go b/config/config.go index 998d051..97668d7 100644 --- a/config/config.go +++ b/config/config.go @@ -16,6 +16,7 @@ var ( RabbitMQ *rabbitMQ Sender *email ElasticSearch *elasticsearch + Jaeger *jaeger runtimeViper = viper.New() ) @@ -52,6 +53,7 @@ func configMapping(serviceName string) { OSS = &c.OSS Sender = &c.Email ElasticSearch = &c.ElasticSearch + Jaeger = &c.Jaeger addrList := runtimeViper.GetStringSlice("services." + serviceName + ".addr") Service = &service{ diff --git a/config/types.go b/config/types.go index 9e68534..bf9211e 100644 --- a/config/types.go +++ b/config/types.go @@ -54,6 +54,10 @@ type elasticsearch struct { Host string } +type jaeger struct { + Addr string +} + type config struct { Server server MySQL mySQL @@ -63,4 +67,5 @@ type config struct { OSS oss Email email ElasticSearch elasticsearch + Jaeger jaeger } diff --git a/docker-compose.yml b/docker-compose.yml index e9c66aa..448ae59 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -41,8 +41,8 @@ services: image: bitnami/etcd:3.5 container_name: etcd ports: - - "2379:2379" - - "2380:2380" + - "2389:2379" + - "2390:2380" volumes: - ./data/etcd/data:/bitnami/etcd-data environment: @@ -90,6 +90,32 @@ services: - ./data/kibana:/usr/share/kibana/data networks: - bibi + + jaeger: + image: jaegertracing/all-in-one:latest + container_name: jaeger + restart: always + ports: + - "16686:16686" + - "14268:14268" + - "4318:4318" + environment: + - LOG_LEVEL=debug + network_mode: host + +# hotrod: +# image: jaegertracing/example-hotrod:latest +# container_name: hotrod +# restart: always +# ports: +# - "8080:8080" +# - "8083:8083" +# command: [ "all", "--otel-exporter=otlp" ] +# environment: +# - OTEL_EXPORTER_OTLP_ENDPOINT=http://jaeger:4318 +# network_mode: host +# depends_on: +# - jaeger # rabbitmq: # image: rabbitmq:management # container_name: rabbitmq diff --git a/go.mod b/go.mod index 939373a..8a6cc7d 100644 --- a/go.mod +++ b/go.mod @@ -14,10 +14,13 @@ require ( github.com/elastic/go-elasticsearch/v8 v8.13.1 github.com/go-sql-driver/mysql v1.8.0 github.com/hertz-contrib/jwt v1.0.2 + github.com/hertz-contrib/tracer v0.0.0-20230215022931-b246a2eb0173 github.com/hertz-contrib/websocket v0.1.0 github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible github.com/kitex-contrib/obs-opentelemetry/logging/logrus v0.0.0-20240305123358-828863cc5853 github.com/kitex-contrib/registry-etcd v0.2.2 + github.com/kitex-contrib/tracer-opentracing v0.0.3 + github.com/opentracing/opentracing-go v1.2.0 github.com/pquerna/otp v1.4.0 github.com/redis/go-redis/v9 v9.5.1 github.com/sirupsen/logrus v1.9.2 @@ -25,6 +28,7 @@ require ( github.com/streadway/amqp v1.1.0 github.com/swaggo/swag v1.16.3 github.com/tinylib/msgp v1.1.9 + github.com/uber/jaeger-client-go v2.30.0+incompatible golang.org/x/crypto v0.17.0 golang.org/x/sync v0.5.0 gorm.io/driver/mysql v1.5.6 @@ -33,6 +37,7 @@ require ( require ( filippo.io/edwards25519 v1.1.0 // indirect + github.com/HdrHistogram/hdrhistogram-go v1.1.2 // indirect github.com/KyleBanks/depth v1.2.1 // indirect github.com/PuerkitoBio/purell v1.1.1 // indirect github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect @@ -86,6 +91,7 @@ require ( github.com/oleiade/lane v1.0.1 // indirect github.com/pelletier/go-toml/v2 v2.1.0 // indirect github.com/philhofer/fwd v1.1.2 // indirect + github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect @@ -100,12 +106,14 @@ require ( github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.0 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect + github.com/uber/jaeger-lib v2.4.1+incompatible // indirect go.etcd.io/etcd/api/v3 v3.5.12 // indirect go.etcd.io/etcd/client/pkg/v3 v3.5.12 // indirect go.etcd.io/etcd/client/v3 v3.5.12 // indirect go.opentelemetry.io/otel v1.21.0 // indirect go.opentelemetry.io/otel/metric v1.21.0 // indirect go.opentelemetry.io/otel/trace v1.21.0 // indirect + go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect golang.org/x/arch v0.2.0 // indirect diff --git a/go.sum b/go.sum index caebbc7..e78de69 100644 --- a/go.sum +++ b/go.sum @@ -6,8 +6,11 @@ gioui.org v0.0.0-20210308172011-57750fc8a0a6/go.mod h1:RSH6KIUZ0p2xy5zHDxgAM4zum git.sr.ht/~sbinet/gg v0.3.1/go.mod h1:KGYtlADtqsqANL9ueOFkWymvzUvLMQllU5Ixo+8v3pc= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/HdrHistogram/hdrhistogram-go v1.1.2 h1:5IcZpTvzydCQeHzK4Ef/D5rrSqwxob0t8PQPMybUNFM= +github.com/HdrHistogram/hdrhistogram-go v1.1.2/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo= github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= +github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= @@ -33,6 +36,9 @@ github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA= github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0= github.com/bytedance/go-tagexpr/v2 v2.9.2 h1:QySJaAIQgOEDQBLS3x9BxOWrnhqu5sQ+f6HaZIxD39I= github.com/bytedance/go-tagexpr/v2 v2.9.2/go.mod h1:5qsx05dYOiUXOUgnQ7w3Oz8BYs2qtM/bJokdLb79wRM= +github.com/bytedance/gopkg v0.0.0-20210705062217-74c74ebadcae/go.mod h1:birsdqRCbwnckJbdAvcSao+AzOyibVEoWB55MjpYpB8= +github.com/bytedance/gopkg v0.0.0-20210709064845-3c00f9323f09/go.mod h1:birsdqRCbwnckJbdAvcSao+AzOyibVEoWB55MjpYpB8= +github.com/bytedance/gopkg v0.0.0-20210716082555-acbf5a2aa7e2/go.mod h1:birsdqRCbwnckJbdAvcSao+AzOyibVEoWB55MjpYpB8= github.com/bytedance/gopkg v0.0.0-20220413063733-65bf48ffb3a7/go.mod h1:2ZlV9BaUH4+NXIBF0aMdKKAnHTzqH+iMU4KUjAbL23Q= github.com/bytedance/gopkg v0.0.0-20220509134931-d1878f638986/go.mod h1:2ZlV9BaUH4+NXIBF0aMdKKAnHTzqH+iMU4KUjAbL23Q= github.com/bytedance/gopkg v0.0.0-20220531084716-665b4f21126f/go.mod h1:2ZlV9BaUH4+NXIBF0aMdKKAnHTzqH+iMU4KUjAbL23Q= @@ -54,6 +60,7 @@ github.com/bytedance/sonic v1.11.2/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf5 github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= @@ -87,8 +94,10 @@ github.com/cloudwego/frugal v0.1.6/go.mod h1:9ElktKsh5qd2zDBQ5ENhPSQV7F2dZ/mXlr1 github.com/cloudwego/frugal v0.1.14 h1:vkjQMb5OsPL779RfMdLI4YJZsOH8fR0ewJpTuAVSeiQ= github.com/cloudwego/frugal v0.1.14/go.mod h1:zFBA63ne4+Tz4qayRZFZf+ZVwGqTzb+1Xe3ZDCq+Wfc= github.com/cloudwego/hertz v0.3.2/go.mod h1:hnv3B7eZ6kMv7CKFHT2OC4LU0mA4s5XPyu/SbixLcrU= +github.com/cloudwego/hertz v0.5.2/go.mod h1:K1U0RlU07CDeBINfHNbafH/3j9uSgIW8otbjUys3OPY= github.com/cloudwego/hertz v0.8.1 h1:3Upzd9o5yNPz6rLx70J5xpo5emosKNkmwW00WgQhf/0= github.com/cloudwego/hertz v0.8.1/go.mod h1:WliNtVbwihWHHgAaIQEbVXl0O3aWj0ks1eoPrcEAnjs= +github.com/cloudwego/kitex v0.0.4/go.mod h1:EIjPJ4Dom2ornk7xDCdKpUpOnf4Tulevimh4Tn05OGc= github.com/cloudwego/kitex v0.3.2/go.mod h1:/XD07VpUD9VQWmmoepASgZ6iw//vgWikVA9MpzLC5i0= github.com/cloudwego/kitex v0.4.4/go.mod h1:3FcH5h9Qw+dhRljSzuGSpWuThttA8DvK0BsL7HUYydo= github.com/cloudwego/kitex v0.6.1/go.mod h1:zI1GBrjT0qloTikcCfQTgxg3Ws+yQMyaChEEOcGNUvA= @@ -96,6 +105,8 @@ github.com/cloudwego/kitex v0.9.1 h1:4Rkmngk4b5nHQ6sPM9BNgnW5cb9niB7hzzQBkkfa8/s github.com/cloudwego/kitex v0.9.1/go.mod h1:CBMfRKBuZ9EeSEfeoveC7cR6JG4lY1Bpo+d0Eb7zUDA= github.com/cloudwego/localsession v0.0.2 h1:N9/IDtCPj1fCL9bCTP+DbXx3f40YjVYWcwkJG0YhQkY= github.com/cloudwego/localsession v0.0.2/go.mod h1:kiJxmvAcy4PLgKtEnPS5AXed3xCiXcs7Z+KBHP72Wv8= +github.com/cloudwego/netpoll v0.0.2/go.mod h1:rZOiNI0FYjuvNybXKKhAPUja03loJi/cdv2F55AE6E8= +github.com/cloudwego/netpoll v0.0.3/go.mod h1:rZOiNI0FYjuvNybXKKhAPUja03loJi/cdv2F55AE6E8= github.com/cloudwego/netpoll v0.2.4/go.mod h1:1T2WVuQ+MQw6h6DpE45MohSvDTKdy2DlzCx2KsnPI4E= github.com/cloudwego/netpoll v0.2.6/go.mod h1:1T2WVuQ+MQw6h6DpE45MohSvDTKdy2DlzCx2KsnPI4E= github.com/cloudwego/netpoll v0.3.1/go.mod h1:1T2WVuQ+MQw6h6DpE45MohSvDTKdy2DlzCx2KsnPI4E= @@ -103,6 +114,7 @@ github.com/cloudwego/netpoll v0.4.0/go.mod h1:xVefXptcyheopwNDZjDPcfU6kIjZXZ4nY5 github.com/cloudwego/netpoll v0.5.0/go.mod h1:xVefXptcyheopwNDZjDPcfU6kIjZXZ4nY550k1yH9eQ= github.com/cloudwego/netpoll v0.6.0 h1:JRMkrA1o8k/4quxzg6Q1XM+zIhwZsyoWlq6ef+ht31U= github.com/cloudwego/netpoll v0.6.0/go.mod h1:xVefXptcyheopwNDZjDPcfU6kIjZXZ4nY550k1yH9eQ= +github.com/cloudwego/netpoll-http2 v0.0.4/go.mod h1:iFr5SzJCXIYgBg0ubL0fZiCQ6W36s9p0KjXpV04lmoY= github.com/cloudwego/thriftgo v0.1.2/go.mod h1:LzeafuLSiHA9JTiWC8TIMIq64iadeObgRUhmVG1OC/w= github.com/cloudwego/thriftgo v0.2.4/go.mod h1:8i9AF5uDdWHGqzUhXDlubCjx4MEfKvWXGQlMWyR0tM4= github.com/cloudwego/thriftgo v0.2.7/go.mod h1:8i9AF5uDdWHGqzUhXDlubCjx4MEfKvWXGQlMWyR0tM4= @@ -200,6 +212,7 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= @@ -233,6 +246,8 @@ github.com/henrylee2cn/goutil v0.0.0-20210127050712-89660552f6f8 h1:yE9ULgp02BhY github.com/henrylee2cn/goutil v0.0.0-20210127050712-89660552f6f8/go.mod h1:Nhe/DM3671a5udlv2AdV2ni/MZzgfv2qrPL5nIi3EGQ= github.com/hertz-contrib/jwt v1.0.2 h1:sAW3wqgBDsbPKr5JWJRObY61jg1NqYkUCg+o8UXLsaI= github.com/hertz-contrib/jwt v1.0.2/go.mod h1:3zUSK+44dcw/9z/89JZ+mA0FoyhmVN7Hx+f46ucVV4I= +github.com/hertz-contrib/tracer v0.0.0-20230215022931-b246a2eb0173 h1:gB4maI+sbQhkkbOMfKQYLb8b6JCnQ1XKoQIFV4Upq4c= +github.com/hertz-contrib/tracer v0.0.0-20230215022931-b246a2eb0173/go.mod h1:S9tHCLI6q0HMblvNmE5ZGcKm0xDQnUrrcJZYtqO1zi8= github.com/hertz-contrib/websocket v0.1.0 h1:9awGM2xzKJySbvnDrZMSNQcJEKjk7VYFMzt5VdPycFU= github.com/hertz-contrib/websocket v0.1.0/go.mod h1:VqcJq3L1S6dZlJqa3kY/0FeQKMxGWwijvWhEUNagLmo= github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHLwW0= @@ -251,6 +266,7 @@ github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= @@ -263,6 +279,8 @@ github.com/kitex-contrib/obs-opentelemetry/logging/logrus v0.0.0-20240305123358- github.com/kitex-contrib/obs-opentelemetry/logging/logrus v0.0.0-20240305123358-828863cc5853/go.mod h1:oQTDyY/+vIlKG/9FGhtYASfb+UybIiianqn1RLVhJ3A= github.com/kitex-contrib/registry-etcd v0.2.2 h1:ebrqLpZrkSLSyazD6mrplV3m80GavSnjUusjhf+fvmc= github.com/kitex-contrib/registry-etcd v0.2.2/go.mod h1:Imgvy+EkqExHuJs4+VFK0g1bFWHaCJ0KuK1sofWYZf4= +github.com/kitex-contrib/tracer-opentracing v0.0.3 h1:8SI0OrHTQ8u6eWpemnuaecMBSEVEvWKCWxg2HnnONQU= +github.com/kitex-contrib/tracer-opentracing v0.0.3/go.mod h1:mprt5pxqywFQxlHb7ugfiMdKbABTLI9YrBYs9WmlK5Q= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.1.0/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk= @@ -292,6 +310,7 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ github.com/modern-go/gls v0.0.0-20220109145502-612d0167dce5 h1:uiS4zKYKJVj5F3ID+5iylfKPsEQmBEOucSD9Vgmn0i0= github.com/modern-go/gls v0.0.0-20220109145502-612d0167dce5/go.mod h1:I8AX+yW//L8Hshx6+a1m3bYkwXkpsVjA2795vP4f4oQ= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= @@ -301,6 +320,8 @@ github.com/nyaruka/phonenumbers v1.0.55 h1:bj0nTO88Y68KeUQ/n3Lo2KgK7lM1hF7L9NFuw github.com/nyaruka/phonenumbers v1.0.55/go.mod h1:sDaTZ/KPX5f8qyV9qN+hIm+4ZBARJrupC6LuhshJq1U= github.com/oleiade/lane v1.0.1 h1:hXofkn7GEOubzTwNpeL9MaNy8WxolCYb9cInAIeqShU= github.com/oleiade/lane v1.0.1/go.mod h1:IyTkraa4maLfjq/GmHR+Dxb4kCMtEGeb+qmhlrQ5Mk4= +github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= +github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4= github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= github.com/philhofer/fwd v1.1.2 h1:bnDivRJ1EWPjUIRXV5KfORO897HTbpFAQddBdE8t7Gw= @@ -309,6 +330,7 @@ github.com/phpdave11/gofpdf v1.4.2/go.mod h1:zpO6xFn9yxo3YLyMvW8HcKWVdbNqgIfOOp2 github.com/phpdave11/gofpdi v1.0.12/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= github.com/phpdave11/gofpdi v1.0.13/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= @@ -348,6 +370,7 @@ github.com/soheilhy/cmux v0.1.5 h1:jjzc5WVemNEDTLwv9tlmemhC73tI08BNOIGwBOo10Js= github.com/soheilhy/cmux v0.1.5/go.mod h1:T7TcVDs9LWfQgPlPsdngu6I6QIoyIFZDDC6sNE1GqG0= github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= +github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY= github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0= @@ -360,6 +383,7 @@ github.com/streadway/amqp v1.1.0 h1:py12iX8XSyI7aN/3dUT8DFIDJazNJsVJdxNVEpnQTZM= github.com/streadway/amqp v1.1.0/go.mod h1:WYSrTEYHOXHd0nwFeUXAe2G2hRnQT+deZJJf88uS9Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= @@ -394,6 +418,10 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802 h1:uruHq4 github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= +github.com/uber/jaeger-client-go v2.30.0+incompatible h1:D6wyKGCecFaSRUpo8lCVbaOOb6ThwMmTEbhRwtKR97o= +github.com/uber/jaeger-client-go v2.30.0+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk= +github.com/uber/jaeger-lib v2.4.1+incompatible h1:td4jdvLcExb4cBISKIpHuGoVXh+dVKhn2Um6rjCsSsg= +github.com/uber/jaeger-lib v2.4.1+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U= github.com/v2pro/plz v0.0.0-20221028024117-e5f9aec5b631/go.mod h1:3gacX+hQo+xvl0vtLqCMufzxuNCwt4geAVOMt2LQYfE= github.com/v2pro/quokka v0.0.0-20171201153428-382cb39c6ee6/go.mod h1:0VP5W9AFNVWU8C1QLNeVg8TvzoEkIHWZ4vxtxEVFWUY= github.com/v2pro/wombat v0.0.0-20180402055224-a56dbdcddef2/go.mod h1:wen8nMxrRrUmXnRwH+3wGAW+hyYTHcOrTNhMpxyp/i0= @@ -439,6 +467,8 @@ go.opentelemetry.io/otel/trace v1.21.0 h1:WD9i5gzvoUPuXIXH24ZNBudiarZDKuekPqi/E8 go.opentelemetry.io/otel/trace v1.21.0/go.mod h1:LGbsEB0f9LGjN+OZaQQ26sohbOmiMR+BaslueVtS/qQ= go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lIVU/I= go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM= +go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= +go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= go.uber.org/goleak v1.2.0/go.mod h1:XJYK+MuIchqpmGmUSAzotztawfKvYLUIgg7guXrwVUo= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= @@ -454,6 +484,7 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= @@ -464,6 +495,7 @@ golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20191002040644-a1355ae1e2c3/go.mod h1:NOZ3BPKG0ec/BKJQgnvsSFpcKLM5xXVWnvZS97DWHgE= +golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= @@ -542,6 +574,7 @@ golang.org/x/sys v0.0.0-20210304124612-50617c2ba197/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210415045647-66c3f260301c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210420072515-93ed5bcd2bfe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -589,6 +622,7 @@ golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190927191325-030b2cf1153e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= diff --git a/pkg/tracer/jaeger.go b/pkg/tracer/jaeger.go new file mode 100644 index 0000000..944831c --- /dev/null +++ b/pkg/tracer/jaeger.go @@ -0,0 +1,34 @@ +package tracer + +import ( + "bibi/config" + "fmt" + "github.com/opentracing/opentracing-go" + "github.com/uber/jaeger-client-go" + jaegercfg "github.com/uber/jaeger-client-go/config" +) + +func InitJaegerTracer(serviceName string) /*(opentracing.Tracer, io.Closer) */ { + cfg := jaegercfg.Configuration{ + ServiceName: serviceName, + Sampler: &jaegercfg.SamplerConfig{ + Type: jaeger.SamplerTypeConst, + Param: 1, + }, + Reporter: &jaegercfg.ReporterConfig{ + LogSpans: false, + // 按实际情况替换你的 ip + CollectorEndpoint: config.Jaeger.Addr, + }, + } + + tracer, _, err := cfg.NewTracer( + jaegercfg.Logger(jaeger.StdLogger), + jaegercfg.ZipkinSharedRPCSpan(true), + ) + if err != nil { + panic(fmt.Sprintf("ERROR: cannot init Jaeger: %v\n", err)) + } + opentracing.SetGlobalTracer(tracer) + //return tracer, closer +}