1 Star 0 Fork 0

李文建/protoactor-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
activespan.go 785 Bytes
一键复制 编辑 原始数据 按行查看 历史
yangdiangzb 提交于 2019-06-18 09:51 . fix gofmt and goimports problem
package opentracing
import (
"fmt"
"sync"
"github.com/AsynkronIT/protoactor-go/actor"
"github.com/opentracing/opentracing-go"
)
var activeSpan = sync.Map{}
func getActiveSpan(pid *actor.PID) opentracing.Span {
value, ok := activeSpan.Load(pid)
if !ok {
return nil
}
return value.(opentracing.Span)
}
func clearActiveSpan(pid *actor.PID) {
activeSpan.Delete(pid)
}
func setActiveSpan(pid *actor.PID, span opentracing.Span) {
activeSpan.Store(pid, span)
}
func GetActiveSpan(context actor.Context) opentracing.Span {
span := getActiveSpan(context.Self())
if span == nil {
// TODO: Fix finding the real span always or handle no-span better on receiving side
span = opentracing.StartSpan(fmt.Sprintf("%T/%T", context.Actor(), context.Message()))
}
return span
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/lwj8507/protoactor-go.git
git@gitee.com:lwj8507/protoactor-go.git
lwj8507
protoactor-go
protoactor-go
v0.0.1

搜索帮助