Vasiliy Tolstov
59283b64c9
Some checks failed
codeql / analyze (go) (pull_request) Failing after 3m7s
dependabot-automerge / automerge (pull_request) Has been skipped
prbuild / test (pull_request) Failing after 1m29s
prbuild / lint (pull_request) Failing after 2m33s
autoapprove / autoapprove (pull_request) Failing after 1m24s
automerge / automerge (pull_request) Failing after 3s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
51 lines
820 B
Go
51 lines
820 B
Go
package opentracing
|
|
|
|
import (
|
|
"context"
|
|
"sync"
|
|
"testing"
|
|
|
|
"github.com/opentracing/opentracing-go"
|
|
"go.unistack.org/micro/v3/metadata"
|
|
)
|
|
|
|
func TestStartSpanFromIncomingContext(t *testing.T) {
|
|
md := metadata.New(2)
|
|
md.Set("key", "val")
|
|
|
|
var g sync.WaitGroup
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
defer cancel()
|
|
ctx = metadata.NewIncomingContext(ctx, md)
|
|
|
|
tracer := opentracing.GlobalTracer()
|
|
|
|
g.Add(8000)
|
|
cherr := make(chan error)
|
|
for i := 0; i < 8000; i++ {
|
|
go func() {
|
|
defer g.Done()
|
|
_, sp, err := startSpanFromIncomingContext(ctx, tracer, "test")
|
|
if err != nil {
|
|
cherr <- err
|
|
}
|
|
sp.Finish()
|
|
}()
|
|
}
|
|
|
|
for {
|
|
select {
|
|
default:
|
|
g.Wait()
|
|
close(cherr)
|
|
case err, ok := <-cherr:
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
} else if !ok {
|
|
return
|
|
}
|
|
}
|
|
}
|
|
}
|