@@ -15,6 +15,10 @@ import (
1515)
1616
1717func MyServer (server * http.ServeMux , w http.ResponseWriter , r * http.Request ) {
18+ worker , _ := utils .NewWorker (global .AgentId )
19+
20+ TraceId := global .TraceId + "-" + strconv .Itoa (int (worker .GetId ()))
21+ global .TargetTraceId = TraceId
1822 MyServerTemp (server , w , r )
1923 id := utils .CatGoroutineID ()
2024 go func () {
@@ -24,7 +28,7 @@ func MyServer(server *http.ServeMux, w http.ResponseWriter, r *http.Request) {
2428 for k , v := range r .Header {
2529 headerBase += k + ": " + strings .Join (v , "," ) + "\n "
2630 }
27- tranceID := global . TraceId + "." + strconv .Itoa (global .AgentId ) + ".0.0.0"
31+ tranceID := TraceId + "." + strconv .Itoa (global .AgentId ) + ".0.0.0"
2832 headerBase += "dt-traceid:" + tranceID
2933 if t .Kind () == reflect .Ptr {
3034 buf := t .
@@ -51,7 +55,6 @@ func MyServer(server *http.ServeMux, w http.ResponseWriter, r *http.Request) {
5155 if r .TLS != nil {
5256 scheme = "https"
5357 }
54- worker , _ := utils .NewWorker (global .AgentId )
5558 onlyKey := int (worker .GetId ())
5659
5760 HookGroup := & request.UploadReq {
@@ -71,6 +74,7 @@ func MyServer(server *http.ServeMux, w http.ResponseWriter, r *http.Request) {
7174 ReqBody : body ,
7275 QueryString : r .URL .RawQuery ,
7376 Pool : []request.Pool {},
77+ TraceId : tranceID ,
7478 },
7579 },
7680 }
@@ -96,7 +100,7 @@ func MyServer(server *http.ServeMux, w http.ResponseWriter, r *http.Request) {
96100 global .PoolTreeMap .Range (func (key , value interface {}) bool {
97101 if value .(* request.PoolTree ).IsThisBegin (id ) {
98102 global .PoolTreeMap .Delete (key )
99- value .(* request.PoolTree ).FMT (& HookGroup .Detail .Function .Pool , worker , goroutineIDs , "" )
103+ value .(* request.PoolTree ).FMT (& HookGroup .Detail .Function .Pool , worker , goroutineIDs , HookGroup . Detail . Function . TraceId )
100104 return false
101105 }
102106 return true
0 commit comments