Skip to content

Commit

Permalink
add response trace log for client streaming
Browse files Browse the repository at this point in the history
  • Loading branch information
yangzhouhan committed Jul 23, 2015
1 parent dc36cdb commit 0252e09
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions call.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func Invoke(ctx context.Context, method string, args, reply interface{}, cc *Cli
return toRPCErr(err)
}
if EnableTracing {
c.traceInfo.tr.LazyLog(payload{args}, true)
c.traceInfo.tr.LazyLog(&fmtStringer{"sent: %v", []interface{}{payload{args}}}, true)
}
stream, err = sendRequest(ctx, cc.dopts.codec, callHdr, t, args, topts)
if err != nil {
Expand All @@ -184,7 +184,7 @@ func Invoke(ctx context.Context, method string, args, reply interface{}, cc *Cli
continue
}
if EnableTracing {
c.traceInfo.tr.LazyLog(payload{reply}, true)
c.traceInfo.tr.LazyLog(&fmtStringer{"received: %v", []interface{}{payload{reply}}}, true)
}
t.CloseStream(stream, lastErr)
if lastErr != nil {
Expand Down
9 changes: 8 additions & 1 deletion stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func (cs *clientStream) SendMsg(m interface{}) (err error) {
if cs.tracing {
cs.mu.Lock()
if cs.traceInfo.tr != nil {
cs.traceInfo.tr.LazyLog(payload{m}, true)
cs.traceInfo.tr.LazyLog(&fmtStringer{"sent: %v", []interface{}{payload{m}}}, true)
}
cs.mu.Unlock()
}
Expand All @@ -187,6 +187,13 @@ func (cs *clientStream) SendMsg(m interface{}) (err error) {
}

func (cs *clientStream) RecvMsg(m interface{}) (err error) {
if cs.tracing {
cs.mu.Lock()
if cs.traceInfo.tr != nil {
cs.traceInfo.tr.LazyLog(&fmtStringer{"received: %v", []interface{}{payload{m}}}, true)
}
cs.mu.Unlock()
}
err = recv(cs.p, cs.codec, m)
defer func() {
// err != nil indicates the termination of the stream.
Expand Down

0 comments on commit 0252e09

Please sign in to comment.