Skip to content

Commit

Permalink
fix client context
Browse files Browse the repository at this point in the history
  • Loading branch information
tonybase committed Feb 20, 2021
1 parent 7fb7347 commit e25ebc7
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions middleware/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,12 @@ func Client(opts ...Option) middleware.Middleware {
path string
code int32
)
if info, ok := grpc.FromServerContext(ctx); ok {
if info, ok := grpc.FromClientContext(ctx); ok {
method = "POST"
path = info.FullMethod
} else if info, ok := http.FromServerContext(ctx); ok {
} else if info, ok := http.FromClientContext(ctx); ok {
method = info.Request.Method
if route := mux.CurrentRoute(info.Request); route != nil {
// /path/123 -> /path/{id}
path, _ = route.GetPathTemplate()
} else {
path = info.Request.RequestURI
}
path = info.Request.RequestURI
}
startTime := time.Now()
reply, err := handler(ctx, req)
Expand Down

0 comments on commit e25ebc7

Please sign in to comment.