1 Star 0 Fork 0

李文建/protoactor-go

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
spawnmiddleware.go 1.23 KB
Copy Edit Raw Blame History
Emil Ingerslev authored 2019-02-21 15:51 +08:00 . Add open tracing middleware
package opentracing
import (
"github.com/AsynkronIT/protoactor-go/actor"
"github.com/AsynkronIT/protoactor-go/log"
olog "github.com/opentracing/opentracing-go/log"
)
func SpawnMiddleware() actor.SpawnMiddleware {
return func(next actor.SpawnFunc) actor.SpawnFunc {
return func(id string, props *actor.Props, parentContext actor.SpawnerContext) (pid *actor.PID, e error) {
self := parentContext.Self()
pid, err := next(id, props, parentContext)
if err != nil {
logger.Debug("SPAWN got error trying to spawn", log.Stringer("PID", self), log.TypeOf("ActorType", parentContext.Actor()), log.Error(err))
return pid, err
}
if self != nil {
span := getActiveSpan(self)
if span != nil {
setParentSpan(pid, span)
span.LogFields(olog.String("SpawnPID", pid.String()))
logger.Debug("SPAWN found active span", log.Stringer("PID", self), log.TypeOf("ActorType", parentContext.Actor()), log.Stringer("SpawnedPID", pid))
} else {
logger.Debug("SPAWN no active span on parent", log.Stringer("PID", self), log.TypeOf("ActorType", parentContext.Actor()), log.Stringer("SpawnedPID", pid))
}
} else {
logger.Debug("SPAWN no parent pid", log.Stringer("SpawnedPID", pid))
}
return pid, err
}
}
}
Loading...
马建仓 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

Search