You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-06-25 00:16:49 +02:00
Make SpanContext Immutable (#1573)
* Make SpanContext Immutable * Adds NewSpanContext() constructor and SpanContextConfig{} struct for constructing a new SpanContext when all fields are known * Adds With<field>() methods to SpanContext for deriving a SpanContext with a single field changed. * Updates all uses of SpanContext to use the new API Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com> * Update CHANGELOG.md Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com> * Add tests for new SpanContext constructor and derivation Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com> * Address PR feedback * Fix new uses of SpanContext from main
This commit is contained in:
committed by
GitHub
parent
d75e268053
commit
e88a091a72
@ -210,7 +210,10 @@ func generateSpan(t *testing.T, parallel bool, tr trace.Tracer, option testOptio
|
||||
|
||||
wg := &sync.WaitGroup{}
|
||||
for i := 0; i < option.genNumSpans; i++ {
|
||||
binary.BigEndian.PutUint64(sc.TraceID[0:8], uint64(i+1))
|
||||
tid := sc.TraceID()
|
||||
binary.BigEndian.PutUint64(tid[0:8], uint64(i+1))
|
||||
newSc := sc.WithTraceID(tid)
|
||||
|
||||
wg.Add(1)
|
||||
f := func(sc trace.SpanContext) {
|
||||
ctx := trace.ContextWithRemoteSpanContext(context.Background(), sc)
|
||||
@ -219,9 +222,9 @@ func generateSpan(t *testing.T, parallel bool, tr trace.Tracer, option testOptio
|
||||
wg.Done()
|
||||
}
|
||||
if parallel {
|
||||
go f(sc)
|
||||
go f(newSc)
|
||||
} else {
|
||||
f(sc)
|
||||
f(newSc)
|
||||
}
|
||||
}
|
||||
wg.Wait()
|
||||
@ -230,11 +233,11 @@ func generateSpan(t *testing.T, parallel bool, tr trace.Tracer, option testOptio
|
||||
func getSpanContext() trace.SpanContext {
|
||||
tid, _ := trace.TraceIDFromHex("01020304050607080102040810203040")
|
||||
sid, _ := trace.SpanIDFromHex("0102040810203040")
|
||||
return trace.SpanContext{
|
||||
return trace.NewSpanContext(trace.SpanContextConfig{
|
||||
TraceID: tid,
|
||||
SpanID: sid,
|
||||
TraceFlags: 0x1,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestBatchSpanProcessorShutdown(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user