etcdserver: add propose summary

This commit is contained in:
Xiang Li
2015-02-15 11:36:23 -08:00
committed by Yicheng Qin
parent 83c953b153
commit 95bba154d6
2 changed files with 51 additions and 0 deletions

View File

@ -487,12 +487,22 @@ func (s *EtcdServer) Do(ctx context.Context, r pb.Request) (Response, error) {
return Response{}, err
}
ch := s.w.Register(r.ID)
// TODO: benchmark the cost of time.Now()
// might be sampling?
start := time.Now()
s.r.Propose(ctx, data)
proposePending.Inc()
defer proposePending.Dec()
select {
case x := <-ch:
proposeDurations.Observe(float64(time.Since(start).Nanoseconds() / int64(time.Millisecond)))
resp := x.(Response)
return resp, resp.err
case <-ctx.Done():
proposeFailed.Inc()
s.w.Trigger(r.ID, nil) // GC wait
return Response{}, parseCtxErr(ctx.Err())
case <-s.done: