Golang

golang grpc调用轨迹记录-trace

2019-02-12  本文已影响2人  46d3d081fdf9

在server端引入trace包

"golang.org/x/net/trace"

//添加trace的http监听

func startTrace() {

  trace.AuthRequest = func(req *http.Request) (any, sensitive bool) {

      return true, true

  }

  go http.ListenAndServe(":50051", nil)

  grpclog.Info("Trace listen on 50051")

}

//打开trace开关

func init()  {

  grpc.EnableTracing = true

}

在main函数中调用开启trace

// 开启trace

go startTrace()

查看调用请求的链接:http://localhost:50051/debug/requests

查看时间链接:http://localhost:50051/debug/events

上一篇 下一篇

猜你喜欢

热点阅读