aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/google.golang.org/grpc/trace.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/google.golang.org/grpc/trace.go')
-rw-r--r--vendor/google.golang.org/grpc/trace.go15
1 files changed, 12 insertions, 3 deletions
diff --git a/vendor/google.golang.org/grpc/trace.go b/vendor/google.golang.org/grpc/trace.go
index b419c9e..c1c96de 100644
--- a/vendor/google.golang.org/grpc/trace.go
+++ b/vendor/google.golang.org/grpc/trace.go
@@ -31,7 +31,7 @@ import (
31 31
32// EnableTracing controls whether to trace RPCs using the golang.org/x/net/trace package. 32// EnableTracing controls whether to trace RPCs using the golang.org/x/net/trace package.
33// This should only be set before any RPCs are sent or received by this program. 33// This should only be set before any RPCs are sent or received by this program.
34var EnableTracing = true 34var EnableTracing bool
35 35
36// methodFamily returns the trace family for the given method. 36// methodFamily returns the trace family for the given method.
37// It turns "/pkg.Service/GetFoo" into "pkg.Service". 37// It turns "/pkg.Service/GetFoo" into "pkg.Service".
@@ -76,6 +76,15 @@ func (f *firstLine) String() string {
76 return line.String() 76 return line.String()
77} 77}
78 78
79const truncateSize = 100
80
81func truncate(x string, l int) string {
82 if l > len(x) {
83 return x
84 }
85 return x[:l]
86}
87
79// payload represents an RPC request or response payload. 88// payload represents an RPC request or response payload.
80type payload struct { 89type payload struct {
81 sent bool // whether this is an outgoing payload 90 sent bool // whether this is an outgoing payload
@@ -85,9 +94,9 @@ type payload struct {
85 94
86func (p payload) String() string { 95func (p payload) String() string {
87 if p.sent { 96 if p.sent {
88 return fmt.Sprintf("sent: %v", p.msg) 97 return truncate(fmt.Sprintf("sent: %v", p.msg), truncateSize)
89 } 98 }
90 return fmt.Sprintf("recv: %v", p.msg) 99 return truncate(fmt.Sprintf("recv: %v", p.msg), truncateSize)
91} 100}
92 101
93type fmtStringer struct { 102type fmtStringer struct {