mirror of https://github.com/grpc/grpc-go.git
server side tracing refactoring
This commit is contained in:
parent
bd2da124cc
commit
2aad9ba05f
|
@ -291,7 +291,7 @@ func (s *Server) processUnaryRPC(t transport.ServerTransport, stream *transport.
|
||||||
defer traceInfo.tr.Finish()
|
defer traceInfo.tr.Finish()
|
||||||
traceInfo.firstLine.client = false
|
traceInfo.firstLine.client = false
|
||||||
traceInfo.firstLine.remoteAddr = t.RemoteAddr()
|
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.firstLine.deadline = dl.Sub(time.Now())
|
||||||
}
|
}
|
||||||
traceInfo.tr.LazyLog(&traceInfo.firstLine, false)
|
traceInfo.tr.LazyLog(&traceInfo.firstLine, false)
|
||||||
|
@ -335,7 +335,7 @@ func (s *Server) processUnaryRPC(t transport.ServerTransport, stream *transport.
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
reply, appErr := md.Handler(srv.server, ctx, df)
|
reply, appErr := md.Handler(srv.server, stream.Context(), df)
|
||||||
if appErr != nil {
|
if appErr != nil {
|
||||||
if err, ok := appErr.(rpcError); ok {
|
if err, ok := appErr.(rpcError); ok {
|
||||||
statusCode = err.code
|
statusCode = err.code
|
||||||
|
@ -389,21 +389,18 @@ func (s *Server) processStreamingRPC(t transport.ServerTransport, stream *transp
|
||||||
ss := &serverStream{
|
ss := &serverStream{
|
||||||
t: t,
|
t: t,
|
||||||
s: stream,
|
s: stream,
|
||||||
//ctx: ctx,
|
|
||||||
p: &parser{s: stream},
|
p: &parser{s: stream},
|
||||||
codec: s.opts.codec,
|
codec: s.opts.codec,
|
||||||
tracing: EnableTracing,
|
tracing: EnableTracing,
|
||||||
}
|
}
|
||||||
if ss.tracing {
|
if ss.tracing {
|
||||||
//ss.traceInfo.tr = trace.New("grpc.Recv."+methodFamily(stream.Method()), stream.Method())
|
|
||||||
ss.traceInfo.tr = stream.Trace()
|
ss.traceInfo.tr = stream.Trace()
|
||||||
ss.traceInfo.firstLine.client = false
|
ss.traceInfo.firstLine.client = false
|
||||||
ss.traceInfo.firstLine.remoteAddr = t.RemoteAddr()
|
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.firstLine.deadline = dl.Sub(time.Now())
|
||||||
}
|
}
|
||||||
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)
|
|
||||||
defer func() {
|
defer func() {
|
||||||
ss.mu.Lock()
|
ss.mu.Lock()
|
||||||
if err != nil && err != io.EOF {
|
if err != nil && err != io.EOF {
|
||||||
|
|
Loading…
Reference in New Issue