Skip to content

Commit

Permalink
调整:链路追踪End接受error参数,
Browse files Browse the repository at this point in the history
  • Loading branch information
steden committed Sep 16, 2024
1 parent a5985a5 commit a938536
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions publishEvent.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ func PublishEvent(eventName string, message any) error {
})
try.CatchException(func(exp any) {
err = flog.Error(exp)
eventTraceContext.Error(err)
})
eventTraceContext.End()
eventTraceContext.End(err)
}
return err
}
Expand All @@ -77,16 +76,16 @@ func PublishEventAsync(eventName string, message any) error {
server := fmt.Sprintf("本地Event/%s/%s/%v", core.AppName, core.AppIp, core.AppId)
for _, s := range subscriber.GetValue(eventName) {
go func(s subscribeConsumer) {
var err error
// 创建一个事件消费入口
eventTraceContext := container.Resolve[trace.IManager]().EntryEventConsumer(server, eventName, s.subscribeName)
try := exception.Try(func() {
s.consumerFunc(message, eventArgs)
})
try.CatchException(func(exp any) {
err := flog.Error(exp)
eventTraceContext.Error(err)
err = flog.Error(exp)
})
eventTraceContext.End()
eventTraceContext.End(err)
}(s)
}
return nil
Expand Down

0 comments on commit a938536

Please sign in to comment.