mirror of https://github.com/grpc/grpc-go.git
show RemoteAddr in server trace
This commit is contained in:
parent
a15e3b9562
commit
2bd5f5b1e1
|
@ -291,6 +291,7 @@ func (s *Server) processUnaryRPC(t transport.ServerTransport, stream *transport.
|
||||||
traceInfo.tr = trace.New("grpc.Recv."+methodFamily(stream.Method()), stream.Method())
|
traceInfo.tr = trace.New("grpc.Recv."+methodFamily(stream.Method()), stream.Method())
|
||||||
defer traceInfo.tr.Finish()
|
defer traceInfo.tr.Finish()
|
||||||
traceInfo.firstLine.client = false
|
traceInfo.firstLine.client = false
|
||||||
|
traceInfo.firstLine.remoteAddr = t.RemoteAddr()
|
||||||
traceInfo.tr.LazyLog(&traceInfo.firstLine, false)
|
traceInfo.tr.LazyLog(&traceInfo.firstLine, false)
|
||||||
ctx = trace.NewContext(ctx, traceInfo.tr)
|
ctx = trace.NewContext(ctx, traceInfo.tr)
|
||||||
defer func() {
|
defer func() {
|
||||||
|
@ -397,6 +398,7 @@ func (s *Server) processStreamingRPC(t transport.ServerTransport, stream *transp
|
||||||
if ss.tracing {
|
if ss.tracing {
|
||||||
ss.traceInfo.tr = trace.New("grpc.Recv."+methodFamily(stream.Method()), stream.Method())
|
ss.traceInfo.tr = trace.New("grpc.Recv."+methodFamily(stream.Method()), stream.Method())
|
||||||
ss.traceInfo.firstLine.client = false
|
ss.traceInfo.firstLine.client = false
|
||||||
|
ss.traceInfo.firstLine.remoteAddr = t.RemoteAddr()
|
||||||
ss.traceInfo.tr.LazyLog(&ss.traceInfo.firstLine, false)
|
ss.traceInfo.tr.LazyLog(&ss.traceInfo.firstLine, false)
|
||||||
ss.ctx = trace.NewContext(ss.ctx, ss.traceInfo.tr)
|
ss.ctx = trace.NewContext(ss.ctx, ss.traceInfo.tr)
|
||||||
defer func() {
|
defer func() {
|
||||||
|
|
|
@ -689,3 +689,7 @@ func (t *http2Server) closeStream(s *Stream) {
|
||||||
// other goroutines.
|
// other goroutines.
|
||||||
s.cancel()
|
s.cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *http2Server) RemoteAddr() net.Addr {
|
||||||
|
return t.conn.RemoteAddr()
|
||||||
|
}
|
||||||
|
|
|
@ -390,6 +390,8 @@ type ServerTransport interface {
|
||||||
// should not be accessed any more. All the pending streams and their
|
// should not be accessed any more. All the pending streams and their
|
||||||
// handlers will be terminated asynchronously.
|
// handlers will be terminated asynchronously.
|
||||||
Close() error
|
Close() error
|
||||||
|
// RemoteAddr returns the remote network address.
|
||||||
|
RemoteAddr() net.Addr
|
||||||
}
|
}
|
||||||
|
|
||||||
// StreamErrorf creates an StreamError with the specified error code and description.
|
// StreamErrorf creates an StreamError with the specified error code and description.
|
||||||
|
|
Loading…
Reference in New Issue