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 76aee35 commit 0a6506b
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions cluster/grpc_rpc_client.go
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 0a6506b

Please sign in to comment.