Merge pull request #21256 from karalabe/p2p-packet-metrics

p2p: measure packet throughput too, not just bandwidth
This commit is contained in:
Péter Szilágyi 2020-06-24 09:44:23 +03:00 committed by GitHub
commit c42d1390d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 0 deletions

View File

@ -304,6 +304,7 @@ func (p *Peer) handle(msg Msg) error {
if metrics.Enabled { if metrics.Enabled {
m := fmt.Sprintf("%s/%s/%d/%#02x", ingressMeterName, proto.Name, proto.Version, msg.Code-proto.offset) m := fmt.Sprintf("%s/%s/%d/%#02x", ingressMeterName, proto.Name, proto.Version, msg.Code-proto.offset)
metrics.GetOrRegisterMeter(m, nil).Mark(int64(msg.meterSize)) metrics.GetOrRegisterMeter(m, nil).Mark(int64(msg.meterSize))
metrics.GetOrRegisterMeter(m+"/packets", nil).Mark(1)
} }
select { select {
case proto.in <- msg: case proto.in <- msg:

View File

@ -597,6 +597,7 @@ func (rw *rlpxFrameRW) WriteMsg(msg Msg) error {
if metrics.Enabled && msg.meterCap.Name != "" { // don't meter non-subprotocol messages if metrics.Enabled && msg.meterCap.Name != "" { // don't meter non-subprotocol messages
m := fmt.Sprintf("%s/%s/%d/%#02x", egressMeterName, msg.meterCap.Name, msg.meterCap.Version, msg.meterCode) m := fmt.Sprintf("%s/%s/%d/%#02x", egressMeterName, msg.meterCap.Name, msg.meterCap.Version, msg.meterCode)
metrics.GetOrRegisterMeter(m, nil).Mark(int64(msg.meterSize)) metrics.GetOrRegisterMeter(m, nil).Mark(int64(msg.meterSize))
metrics.GetOrRegisterMeter(m+"/packets", nil).Mark(1)
} }
// write header // write header
headbuf := make([]byte, 32) headbuf := make([]byte, 32)