Skip to content

Commit

Permalink
stats: create new MD for outgoing header if no MD is available (#3357)
Browse files Browse the repository at this point in the history
  • Loading branch information
menghanl authored Feb 4, 2020
1 parent e0e0cbc commit 3ae60eb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions internal/transport/http2_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -680,8 +680,12 @@ func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (_ *Strea
}
}
if t.statsHandler != nil {
header, _ := metadata.FromOutgoingContext(ctx)
header.Set("user-agent", t.userAgent)
header, ok := metadata.FromOutgoingContext(ctx)
if ok {
header.Set("user-agent", t.userAgent)
} else {
header = metadata.Pairs("user-agent", t.userAgent)
}
outHeader := &stats.OutHeader{
Client: true,
FullMethod: callHdr.Method,
Expand Down

0 comments on commit 3ae60eb

Please sign in to comment.