From 5e366258891e471bacd98e99b0f6f048433473aa Mon Sep 17 00:00:00 2001 From: Tanghui Lin Date: Thu, 21 Mar 2019 09:46:01 +0800 Subject: [PATCH] get cmd before done --- proxy/proto/pipe.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/proxy/proto/pipe.go b/proxy/proto/pipe.go index eddbe43e..a8d9378b 100644 --- a/proxy/proto/pipe.go +++ b/proxy/proto/pipe.go @@ -175,13 +175,17 @@ func (mp *msgPipe) pipe() { msg := mp.batch[i] msg.WithError(err) // NOTE: maybe err is nil if prom.On { + cmd := msg.Request().CmdString() + duration := msg.RemoteDur() + msg.Done() if err != nil { - prom.ErrIncr(nc.Cluster(), nc.Addr(), msg.Request().CmdString(), perr.Cause(err).Error()) + prom.ErrIncr(nc.Cluster(), nc.Addr(), cmd, perr.Cause(err).Error()) } else { - prom.HandleTime(nc.Cluster(), nc.Addr(), msg.Request().CmdString(), int64(msg.RemoteDur()/time.Microsecond)) + prom.HandleTime(nc.Cluster(), nc.Addr(), cmd, int64(duration/time.Microsecond)) } + } else { + msg.Done() } - msg.Done() } mp.count = 0 if err != nil {