Skip to content

Commit

Permalink
实现ws的链路追踪
Browse files Browse the repository at this point in the history
  • Loading branch information
steden committed Sep 16, 2024
1 parent 500f8e6 commit 94597f8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions traceManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (*traceManager) EntryWebApi(domain string, path string, method string, cont
}

// EntryWebSocket WebSocket入口
func (*traceManager) EntryWebSocket(domain string, path string, contentType string, header map[string]string, requestIp string) trace.ITraceContext {
func (*traceManager) EntryWebSocket(domain string, path string, header map[string]string, requestIp string) trace.ITraceContext {
headerDictionary := collections.NewDictionaryFromMap(header)
traceId := parse.ToString(headerDictionary.GetValue("Trace-Id"))
traceLevel := parse.ToInt(headerDictionary.GetValue("Trace-Level"))
Expand All @@ -83,7 +83,7 @@ func (*traceManager) EntryWebSocket(domain string, path string, contentType stri
WebDomain: domain,
WebPath: path,
WebMethod: "WEBSOCKET",
WebContentType: contentType,
WebContentType: "",
WebHeaders: headerDictionary.ToDictionary(),
WebRequestBody: "Conn",
WebRequestIp: requestIp,
Expand Down
4 changes: 4 additions & 0 deletions trackContext.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ func (receiver *TraceContext) SetBody(requestBody string, statusCode int, respon
receiver.WebContext.WebResponseBody = responseBody
}

func (receiver *TraceContext) SetResponseBody(responseBody string) {
receiver.WebContext.WebResponseBody = responseBody
}

func (receiver *TraceContext) GetTraceId() string {
return receiver.TraceId
}
Expand Down

0 comments on commit 94597f8

Please sign in to comment.