Skip to content

Commit

Permalink
tracer: Atomically load error count when creating child spans
Browse files Browse the repository at this point in the history
Otherwise, it's subject to a data race while concurrently creating child
spans and erroring. The count is written via atomic increments.
  • Loading branch information
JDeuce committed Apr 14, 2023
1 parent 259b49f commit 374fd5a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ddtrace/tracer/spancontext.go
Expand Up @@ -113,7 +113,7 @@ func newSpanContext(span *span, parent *spanContext) *spanContext {
context.traceID.SetUpper(parent.traceID.Upper())
context.trace = parent.trace
context.origin = parent.origin
context.errors = parent.errors
context.errors = atomic.LoadInt32(&parent.errors)
parent.ForeachBaggageItem(func(k, v string) bool {
context.setBaggageItem(k, v)
return true
Expand Down

0 comments on commit 374fd5a

Please sign in to comment.