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 f2dc8c4 commit 9c983b9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion trace/emptyManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type EmptyManager struct {
func (*EmptyManager) EntryWebApi(domain string, path string, method string, contentType string, header map[string]string, requestIp string) ITraceContext {
return &emptyTraceContext{}
}
func (*EmptyManager) EntryWebSocket(domain string, path string, contentType string, header map[string]string, requestIp string) ITraceContext {
func (*EmptyManager) EntryWebSocket(domain string, path string, header map[string]string, requestIp string) ITraceContext {
return &emptyTraceContext{}
}

Expand Down Expand Up @@ -62,6 +62,7 @@ type emptyTraceContext struct{}

func (*emptyTraceContext) Error(err error) {}
func (*emptyTraceContext) SetBody(requestBody string, statusCode int, responseBody string) {}
func (*emptyTraceContext) SetResponseBody(responseBody string) {}
func (*emptyTraceContext) GetTraceId() string { return "" }
func (*emptyTraceContext) GetTraceLevel() int { return 0 }
func (*emptyTraceContext) GetStartTs() int64 { return 0 }
Expand Down
2 changes: 1 addition & 1 deletion trace/iManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type IManager interface {
// EntryWebApi 创建webapi的链路追踪入口
EntryWebApi(domain string, path string, method string, contentType string, headerDictionary map[string]string, requestIp string) ITraceContext
// EntryWebSocket 创建WebSocket的链路追踪入口
EntryWebSocket(domain string, path string, contentType string, headerDictionary map[string]string, requestIp string) ITraceContext
EntryWebSocket(domain string, path string, headerDictionary map[string]string, requestIp string) ITraceContext
// EntryMqConsumer 创建MQ消费入口
EntryMqConsumer(parentTraceId, parentAppName, server string, queueName string, routingKey string) ITraceContext
// EntryQueueConsumer 创建Queue消费入口
Expand Down
2 changes: 2 additions & 0 deletions trace/iTraceContext.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ type ITraceContext interface {
End(err error)
// SetBody 设置webapi的响应报文
SetBody(requestBody string, statusCode int, responseBody string)
// SetResponseBody 设置webapi的响应报文
SetResponseBody(responseBody string)
// GetTraceId 获取traceId
GetTraceId() string
// GetStartTs 获取链路开启时间
Expand Down

0 comments on commit 9c983b9

Please sign in to comment.