feat: 尝试添加 tracing

This commit is contained in:
2025-01-22 12:56:41 +08:00
parent 9d82d63a64
commit 275221adbd
7 changed files with 415 additions and 2 deletions
+2 -2
View File
@@ -22,14 +22,14 @@ func NewRegisterService(Context context.Context, RequestContext *app.RequestCont
}
// curl -X POST 10.42.0.106:8080/register
// 使用POST请求,即可看到效果
// 使用 POST 请求,即可看到效果
// 使用了 rpc 调用,并且使用 hertz 框架暴露出 http 接口
func (h *RegisterService) Run(req *facade.RegisterReq) (resp *facade.RegisterResp, err error) {
//defer func() {
// hlog.CtxInfof(h.Context, "req = %+v", req)
// hlog.CtxInfof(h.Context, "resp = %+v", resp)
//}()
// todo edit your code
r, err := consul.NewConsulResolver("consul:8500")
if err != nil {
return nil, err
+3
View File
@@ -4,6 +4,7 @@ import (
"github.com/suyiiyii/hertz101/app/user/biz/dal"
"github.com/suyiiyii/hertz101/app/user/biz/dal/mysql"
"github.com/suyiiyii/hertz101/app/user/biz/dal/query"
"github.com/suyiiyii/hertz101/common/mtl"
"net"
"time"
@@ -28,6 +29,8 @@ func main() {
query.Use(mysql.DB)
opts := kitexInit()
mtl.InitTracing(conf.GetConf().Kitex.Service)
svr := userservice.NewServer(new(UserServiceImpl), opts...)
err := svr.Run()