fix methodFamily breakage
diff --git a/call.go b/call.go
index 8b68809..b5f9292 100644
--- a/call.go
+++ b/call.go
@@ -117,7 +117,7 @@
}
}()
if EnableTracing {
- c.traceInfo.tr = trace.New("grpc.Sent."+methodFamily(method), method)
+ c.traceInfo.tr = trace.New("grpc.Sent."+transport.MethodFamily(method), method)
defer c.traceInfo.tr.Finish()
c.traceInfo.firstLine.client = true
if deadline, ok := ctx.Deadline(); ok {
diff --git a/stream.go b/stream.go
index 6dc4744..28938a3 100644
--- a/stream.go
+++ b/stream.go
@@ -126,7 +126,7 @@
tracing: EnableTracing,
}
if cs.tracing {
- cs.traceInfo.tr = trace.New("grpc.Sent."+methodFamily(method), method)
+ cs.traceInfo.tr = trace.New("grpc.Sent."+transport.MethodFamily(method), method)
cs.traceInfo.firstLine.client = true
if deadline, ok := ctx.Deadline(); ok {
cs.traceInfo.firstLine.deadline = deadline.Sub(time.Now())
diff --git a/trace.go b/trace.go
index cde04fb..9b88444 100644
--- a/trace.go
+++ b/trace.go
@@ -38,7 +38,6 @@
"fmt"
"io"
"net"
- "strings"
"time"
"golang.org/x/net/trace"
@@ -48,19 +47,6 @@
// This should only be set before any RPCs are sent or received by this program.
var EnableTracing = true
-// methodFamily returns the trace family for the given method.
-// It turns "/pkg.Service/GetFoo" into "pkg.Service".
-func methodFamily(m string) string {
- m = strings.TrimPrefix(m, "/") // remove leading slash
- if i := strings.Index(m, "/"); i >= 0 {
- m = m[:i] // remove everything from second slash
- }
- if i := strings.LastIndex(m, "."); i >= 0 {
- m = m[i+1:] // cut down to last dotted component
- }
- return m
-}
-
// traceInfo contains tracing information for an RPC.
type traceInfo struct {
tr trace.Trace
diff --git a/transport/http2_server.go b/transport/http2_server.go
index b7cc536..0fcf6c4 100644
--- a/transport/http2_server.go
+++ b/transport/http2_server.go
@@ -44,8 +44,8 @@
"golang.org/x/net/context"
"golang.org/x/net/http2"
- "golang.org/x/net/trace"
"golang.org/x/net/http2/hpack"
+ "golang.org/x/net/trace"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/grpclog"
diff --git a/transport/transport.go b/transport/transport.go
index 7ea2a11..93efeae 100644
--- a/transport/transport.go
+++ b/transport/transport.go
@@ -43,6 +43,7 @@
"fmt"
"io"
"net"
+ "strings"
"sync"
"time"
@@ -53,6 +54,19 @@
"google.golang.org/grpc/metadata"
)
+// MethodFamily returns the trace family for the given method.
+// It turns "/pkg.Service/GetFoo" into "pkg.Service".
+func MethodFamily(m string) string {
+ m = strings.TrimPrefix(m, "/") // remove leading slash
+ if i := strings.Index(m, "/"); i >= 0 {
+ m = m[:i] // remove everything from second slash
+ }
+ if i := strings.LastIndex(m, "."); i >= 0 {
+ m = m[i+1:] // cut down to last dotted component
+ }
+ return m
+}
+
// recvMsg represents the received msg from the transport. All transport
// protocol specific info has been removed.
type recvMsg struct {