server side tracing refactoring

This commit is contained in:
iamqizhao 2015-10-02 15:06:41 -07:00
parent bd2da124cc
commit 2aad9ba05f
1 changed files with 3 additions and 6 deletions

View File

@ -291,7 +291,7 @@ func (s *Server) processUnaryRPC(t transport.ServerTransport, stream *transport.
defer traceInfo.tr.Finish()
traceInfo.firstLine.client = false
traceInfo.firstLine.remoteAddr = t.RemoteAddr()
if dl, ok := ctx.Deadline(); ok {
if dl, ok := stream.Context().Deadline(); ok {
traceInfo.firstLine.deadline = dl.Sub(time.Now())
}
traceInfo.tr.LazyLog(&traceInfo.firstLine, false)
@ -335,7 +335,7 @@ func (s *Server) processUnaryRPC(t transport.ServerTransport, stream *transport.
}
return nil
}
reply, appErr := md.Handler(srv.server, ctx, df)
reply, appErr := md.Handler(srv.server, stream.Context(), df)
if appErr != nil {
if err, ok := appErr.(rpcError); ok {
statusCode = err.code
@ -389,21 +389,18 @@ func (s *Server) processStreamingRPC(t transport.ServerTransport, stream *transp
ss := &serverStream{
t: t,
s: stream,
//ctx: ctx,
p: &parser{s: stream},
codec: s.opts.codec,
tracing: EnableTracing,
}
if ss.tracing {
//ss.traceInfo.tr = trace.New("grpc.Recv."+methodFamily(stream.Method()), stream.Method())
ss.traceInfo.tr = stream.Trace()
ss.traceInfo.firstLine.client = false
ss.traceInfo.firstLine.remoteAddr = t.RemoteAddr()
if dl, ok := ctx.Deadline(); ok {
if dl, ok := stream.Context().Deadline(); ok {
ss.traceInfo.firstLine.deadline = dl.Sub(time.Now())
}
ss.traceInfo.tr.LazyLog(&ss.traceInfo.firstLine, false)
ss.ctx = trace.NewContext(ss.ctx, ss.traceInfo.tr)
defer func() {
ss.mu.Lock()
if err != nil && err != io.EOF {