les: fix request serving metrics (#20507)

This commit is contained in:
gary rong 2020-01-08 21:08:56 +08:00 committed by Péter Szilágyi
parent 8a63f7f504
commit 4d663d57d6

View File

@ -273,7 +273,6 @@ func (h *serverHandler) handleMsg(p *peer, wg *sync.WaitGroup) error {
if metrics.EnabledExpensive { if metrics.EnabledExpensive {
miscInHeaderPacketsMeter.Mark(1) miscInHeaderPacketsMeter.Mark(1)
miscInHeaderTrafficMeter.Mark(int64(msg.Size)) miscInHeaderTrafficMeter.Mark(int64(msg.Size))
defer func(start time.Time) { miscServingTimeHeaderTimer.UpdateSince(start) }(time.Now())
} }
var req struct { var req struct {
ReqID uint64 ReqID uint64
@ -377,6 +376,7 @@ func (h *serverHandler) handleMsg(p *peer, wg *sync.WaitGroup) error {
if metrics.EnabledExpensive { if metrics.EnabledExpensive {
miscOutHeaderPacketsMeter.Mark(1) miscOutHeaderPacketsMeter.Mark(1)
miscOutHeaderTrafficMeter.Mark(int64(reply.size())) miscOutHeaderTrafficMeter.Mark(int64(reply.size()))
miscServingTimeHeaderTimer.Update(time.Duration(task.servingTime))
} }
}() }()
} }
@ -386,7 +386,6 @@ func (h *serverHandler) handleMsg(p *peer, wg *sync.WaitGroup) error {
if metrics.EnabledExpensive { if metrics.EnabledExpensive {
miscInBodyPacketsMeter.Mark(1) miscInBodyPacketsMeter.Mark(1)
miscInBodyTrafficMeter.Mark(int64(msg.Size)) miscInBodyTrafficMeter.Mark(int64(msg.Size))
defer func(start time.Time) { miscServingTimeBodyTimer.UpdateSince(start) }(time.Now())
} }
var req struct { var req struct {
ReqID uint64 ReqID uint64
@ -426,6 +425,7 @@ func (h *serverHandler) handleMsg(p *peer, wg *sync.WaitGroup) error {
if metrics.EnabledExpensive { if metrics.EnabledExpensive {
miscOutBodyPacketsMeter.Mark(1) miscOutBodyPacketsMeter.Mark(1)
miscOutBodyTrafficMeter.Mark(int64(reply.size())) miscOutBodyTrafficMeter.Mark(int64(reply.size()))
miscServingTimeBodyTimer.Update(time.Duration(task.servingTime))
} }
}() }()
} }
@ -435,7 +435,6 @@ func (h *serverHandler) handleMsg(p *peer, wg *sync.WaitGroup) error {
if metrics.EnabledExpensive { if metrics.EnabledExpensive {
miscInCodePacketsMeter.Mark(1) miscInCodePacketsMeter.Mark(1)
miscInCodeTrafficMeter.Mark(int64(msg.Size)) miscInCodeTrafficMeter.Mark(int64(msg.Size))
defer func(start time.Time) { miscServingTimeCodeTimer.UpdateSince(start) }(time.Now())
} }
var req struct { var req struct {
ReqID uint64 ReqID uint64
@ -498,6 +497,7 @@ func (h *serverHandler) handleMsg(p *peer, wg *sync.WaitGroup) error {
if metrics.EnabledExpensive { if metrics.EnabledExpensive {
miscOutCodePacketsMeter.Mark(1) miscOutCodePacketsMeter.Mark(1)
miscOutCodeTrafficMeter.Mark(int64(reply.size())) miscOutCodeTrafficMeter.Mark(int64(reply.size()))
miscServingTimeCodeTimer.Update(time.Duration(task.servingTime))
} }
}() }()
} }
@ -507,7 +507,6 @@ func (h *serverHandler) handleMsg(p *peer, wg *sync.WaitGroup) error {
if metrics.EnabledExpensive { if metrics.EnabledExpensive {
miscInReceiptPacketsMeter.Mark(1) miscInReceiptPacketsMeter.Mark(1)
miscInReceiptTrafficMeter.Mark(int64(msg.Size)) miscInReceiptTrafficMeter.Mark(int64(msg.Size))
defer func(start time.Time) { miscServingTimeReceiptTimer.UpdateSince(start) }(time.Now())
} }
var req struct { var req struct {
ReqID uint64 ReqID uint64
@ -555,6 +554,7 @@ func (h *serverHandler) handleMsg(p *peer, wg *sync.WaitGroup) error {
if metrics.EnabledExpensive { if metrics.EnabledExpensive {
miscOutReceiptPacketsMeter.Mark(1) miscOutReceiptPacketsMeter.Mark(1)
miscOutReceiptTrafficMeter.Mark(int64(reply.size())) miscOutReceiptTrafficMeter.Mark(int64(reply.size()))
miscServingTimeReceiptTimer.Update(time.Duration(task.servingTime))
} }
}() }()
} }
@ -564,7 +564,6 @@ func (h *serverHandler) handleMsg(p *peer, wg *sync.WaitGroup) error {
if metrics.EnabledExpensive { if metrics.EnabledExpensive {
miscInTrieProofPacketsMeter.Mark(1) miscInTrieProofPacketsMeter.Mark(1)
miscInTrieProofTrafficMeter.Mark(int64(msg.Size)) miscInTrieProofTrafficMeter.Mark(int64(msg.Size))
defer func(start time.Time) { miscServingTimeTrieProofTimer.UpdateSince(start) }(time.Now())
} }
var req struct { var req struct {
ReqID uint64 ReqID uint64
@ -658,6 +657,7 @@ func (h *serverHandler) handleMsg(p *peer, wg *sync.WaitGroup) error {
if metrics.EnabledExpensive { if metrics.EnabledExpensive {
miscOutTrieProofPacketsMeter.Mark(1) miscOutTrieProofPacketsMeter.Mark(1)
miscOutTrieProofTrafficMeter.Mark(int64(reply.size())) miscOutTrieProofTrafficMeter.Mark(int64(reply.size()))
miscServingTimeTrieProofTimer.Update(time.Duration(task.servingTime))
} }
}() }()
} }
@ -667,7 +667,6 @@ func (h *serverHandler) handleMsg(p *peer, wg *sync.WaitGroup) error {
if metrics.EnabledExpensive { if metrics.EnabledExpensive {
miscInHelperTriePacketsMeter.Mark(1) miscInHelperTriePacketsMeter.Mark(1)
miscInHelperTrieTrafficMeter.Mark(int64(msg.Size)) miscInHelperTrieTrafficMeter.Mark(int64(msg.Size))
defer func(start time.Time) { miscServingTimeHelperTrieTimer.UpdateSince(start) }(time.Now())
} }
var req struct { var req struct {
ReqID uint64 ReqID uint64
@ -733,6 +732,7 @@ func (h *serverHandler) handleMsg(p *peer, wg *sync.WaitGroup) error {
if metrics.EnabledExpensive { if metrics.EnabledExpensive {
miscOutHelperTriePacketsMeter.Mark(1) miscOutHelperTriePacketsMeter.Mark(1)
miscOutHelperTrieTrafficMeter.Mark(int64(reply.size())) miscOutHelperTrieTrafficMeter.Mark(int64(reply.size()))
miscServingTimeHelperTrieTimer.Update(time.Duration(task.servingTime))
} }
}() }()
} }
@ -742,7 +742,6 @@ func (h *serverHandler) handleMsg(p *peer, wg *sync.WaitGroup) error {
if metrics.EnabledExpensive { if metrics.EnabledExpensive {
miscInTxsPacketsMeter.Mark(1) miscInTxsPacketsMeter.Mark(1)
miscInTxsTrafficMeter.Mark(int64(msg.Size)) miscInTxsTrafficMeter.Mark(int64(msg.Size))
defer func(start time.Time) { miscServingTimeTxTimer.UpdateSince(start) }(time.Now())
} }
var req struct { var req struct {
ReqID uint64 ReqID uint64
@ -782,6 +781,7 @@ func (h *serverHandler) handleMsg(p *peer, wg *sync.WaitGroup) error {
if metrics.EnabledExpensive { if metrics.EnabledExpensive {
miscOutTxsPacketsMeter.Mark(1) miscOutTxsPacketsMeter.Mark(1)
miscOutTxsTrafficMeter.Mark(int64(reply.size())) miscOutTxsTrafficMeter.Mark(int64(reply.size()))
miscServingTimeTxTimer.Update(time.Duration(task.servingTime))
} }
}() }()
} }
@ -791,7 +791,6 @@ func (h *serverHandler) handleMsg(p *peer, wg *sync.WaitGroup) error {
if metrics.EnabledExpensive { if metrics.EnabledExpensive {
miscInTxStatusPacketsMeter.Mark(1) miscInTxStatusPacketsMeter.Mark(1)
miscInTxStatusTrafficMeter.Mark(int64(msg.Size)) miscInTxStatusTrafficMeter.Mark(int64(msg.Size))
defer func(start time.Time) { miscServingTimeTxStatusTimer.UpdateSince(start) }(time.Now())
} }
var req struct { var req struct {
ReqID uint64 ReqID uint64
@ -819,6 +818,7 @@ func (h *serverHandler) handleMsg(p *peer, wg *sync.WaitGroup) error {
if metrics.EnabledExpensive { if metrics.EnabledExpensive {
miscOutTxStatusPacketsMeter.Mark(1) miscOutTxStatusPacketsMeter.Mark(1)
miscOutTxStatusTrafficMeter.Mark(int64(reply.size())) miscOutTxStatusTrafficMeter.Mark(int64(reply.size()))
miscServingTimeTxStatusTimer.Update(time.Duration(task.servingTime))
} }
}() }()
} }