Skip to content

Commit

Permalink
contrib/google.golang.org/grpc: fix race condition when setting metad…
Browse files Browse the repository at this point in the history
…ata (#302)
  • Loading branch information
dd-caleb authored Aug 6, 2018
1 parent 888c7c4 commit 2ef3281
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion contrib/google.golang.org/grpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,10 @@ func injectSpanIntoContext(ctx context.Context) context.Context {
return ctx
}
md, ok := metadata.FromIncomingContext(ctx)
if !ok {
if ok {
// we have to copy the metadata because its not safe to modify
md = md.Copy()
} else {
md = metadata.MD{}
}
if err := tracer.Inject(span.Context(), grpcutil.MDCarrier(md)); err != nil {
Expand Down

0 comments on commit 2ef3281

Please sign in to comment.