github.com/asynkron/protoactor-go@v0.0.0-20240308120642-ef91a6abee75/actor/middleware/opentracing/parentspan.go (about)

     1  package opentracing
     2  
     3  import (
     4  	"sync"
     5  
     6  	"github.com/asynkron/protoactor-go/actor"
     7  	"github.com/opentracing/opentracing-go"
     8  )
     9  
    10  var parentSpans = sync.Map{}
    11  
    12  func getAndClearParentSpan(pid *actor.PID) opentracing.Span {
    13  	value, ok := parentSpans.Load(pid)
    14  	if !ok {
    15  		return nil
    16  	}
    17  
    18  	parentSpans.Delete(pid)
    19  
    20  	span, _ := value.(opentracing.Span)
    21  
    22  	return span
    23  }
    24  
    25  func setParentSpan(pid *actor.PID, span opentracing.Span) {
    26  	parentSpans.Store(pid, span)
    27  }