Merge pull request #373 from iamqizhao/master
show RemoteAddr in server trace
diff --git a/server.go b/server.go
index 181e38c..e817f38 100644
--- a/server.go
+++ b/server.go
@@ -291,6 +291,7 @@
traceInfo.tr = trace.New("grpc.Recv."+methodFamily(stream.Method()), stream.Method())
defer traceInfo.tr.Finish()
traceInfo.firstLine.client = false
+ traceInfo.firstLine.remoteAddr = t.RemoteAddr()
traceInfo.tr.LazyLog(&traceInfo.firstLine, false)
ctx = trace.NewContext(ctx, traceInfo.tr)
defer func() {
@@ -397,6 +398,7 @@
if ss.tracing {
ss.traceInfo.tr = trace.New("grpc.Recv."+methodFamily(stream.Method()), stream.Method())
ss.traceInfo.firstLine.client = false
+ ss.traceInfo.firstLine.remoteAddr = t.RemoteAddr()
ss.traceInfo.tr.LazyLog(&ss.traceInfo.firstLine, false)
ss.ctx = trace.NewContext(ss.ctx, ss.traceInfo.tr)
defer func() {
diff --git a/transport/http2_server.go b/transport/http2_server.go
index 057d936..c9a2a36 100644
--- a/transport/http2_server.go
+++ b/transport/http2_server.go
@@ -689,3 +689,7 @@
// other goroutines.
s.cancel()
}
+
+func (t *http2Server) RemoteAddr() net.Addr {
+ return t.conn.RemoteAddr()
+}
diff --git a/transport/transport.go b/transport/transport.go
index 2dd38a8..d33f2de 100644
--- a/transport/transport.go
+++ b/transport/transport.go
@@ -390,6 +390,8 @@
// should not be accessed any more. All the pending streams and their
// handlers will be terminated asynchronously.
Close() error
+ // RemoteAddr returns the remote network address.
+ RemoteAddr() net.Addr
}
// StreamErrorf creates an StreamError with the specified error code and description.