Skip to content

Commit

Permalink
fix on grpc report
Browse files Browse the repository at this point in the history
  • Loading branch information
henrod committed Apr 9, 2019
1 parent 1f00b64 commit fbe0c12
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions cluster/grpc_rpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,14 @@ func (gs *GRPCClient) Call(ctx context.Context, rpcType protos.RPCType, route *r
}
if c, ok := gs.clientMap.Load(server.ID); ok {
ctxT, done := context.WithTimeout(ctx, gs.reqTimeout)
defer done()

defer func() {
if gs.metricsReporters != nil {
startTime := time.Now()
ctxT = pcontext.AddToPropagateCtx(ctxT, constants.StartTimeKey, startTime.UnixNano())
ctxT = pcontext.AddToPropagateCtx(ctxT, constants.RouteKey, route.String())
metrics.ReportTimingFromCtx(ctx, gs.metricsReporters, "rpc", err)
}
done()
}()
if gs.metricsReporters != nil {
startTime := time.Now()
ctxT = pcontext.AddToPropagateCtx(ctxT, constants.StartTimeKey, startTime.UnixNano())
ctxT = pcontext.AddToPropagateCtx(ctxT, constants.RouteKey, route.String())
defer metrics.ReportTimingFromCtx(ctxT, gs.metricsReporters, "rpc", err)
}

res, err := c.(protos.PitayaClient).Call(ctxT, &req)
if err != nil {
Expand Down

0 comments on commit fbe0c12

Please sign in to comment.