stats: add client side user agent to outgoing header (#3331)
This commit is contained in:
@ -680,14 +680,15 @@ func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (_ *Strea
|
||||
}
|
||||
}
|
||||
if t.statsHandler != nil {
|
||||
header, _, _ := metadata.FromOutgoingContextRaw(ctx)
|
||||
header, _ := metadata.FromOutgoingContext(ctx)
|
||||
header.Set("user-agent", t.userAgent)
|
||||
outHeader := &stats.OutHeader{
|
||||
Client: true,
|
||||
FullMethod: callHdr.Method,
|
||||
RemoteAddr: t.remoteAddr,
|
||||
LocalAddr: t.localAddr,
|
||||
Compression: callHdr.SendCompress,
|
||||
Header: header.Copy(),
|
||||
Header: header,
|
||||
}
|
||||
t.statsHandler.HandleRPC(s.ctx, outHeader)
|
||||
}
|
||||
|
@ -46,8 +46,9 @@ type rpcCtxKey struct{}
|
||||
var (
|
||||
// For headers sent to server:
|
||||
testMetadata = metadata.MD{
|
||||
"key1": []string{"value1"},
|
||||
"key2": []string{"value2"},
|
||||
"key1": []string{"value1"},
|
||||
"key2": []string{"value2"},
|
||||
"user-agent": []string{fmt.Sprintf("test/0.0.1 grpc-go/%s", grpc.Version)},
|
||||
}
|
||||
// For headers sent from server:
|
||||
testHeaderMetadata = metadata.MD{
|
||||
@ -220,7 +221,11 @@ func (te *test) clientConn() *grpc.ClientConn {
|
||||
if te.cc != nil {
|
||||
return te.cc
|
||||
}
|
||||
opts := []grpc.DialOption{grpc.WithInsecure(), grpc.WithBlock()}
|
||||
opts := []grpc.DialOption{
|
||||
grpc.WithInsecure(),
|
||||
grpc.WithBlock(),
|
||||
grpc.WithUserAgent("test/0.0.1"),
|
||||
}
|
||||
if te.compress == "gzip" {
|
||||
opts = append(opts,
|
||||
grpc.WithCompressor(grpc.NewGZIPCompressor()),
|
||||
|
Reference in New Issue
Block a user