mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-28 07:36:44 +00:00
content validation metrics
This commit is contained in:
parent
e85b17cf37
commit
c9ddfbf290
2 changed files with 14 additions and 0 deletions
|
|
@ -1410,12 +1410,18 @@ func (p *PortalProtocol) handleOffer(id enode.ID, addr *net.UDPAddr, request *po
|
|||
func (p *PortalProtocol) handleOfferedContents(id enode.ID, keys [][]byte, payload []byte) error {
|
||||
contents, err := decodeContents(payload)
|
||||
if err != nil {
|
||||
if metrics.Enabled {
|
||||
p.portalMetrics.contentInvalidated.Inc(1)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
keyLen := len(keys)
|
||||
contentLen := len(contents)
|
||||
if keyLen != contentLen {
|
||||
if metrics.Enabled {
|
||||
p.portalMetrics.contentInvalidated.Inc(1)
|
||||
}
|
||||
return fmt.Errorf("content keys len %d doesn't match content values len %d", keyLen, contentLen)
|
||||
}
|
||||
|
||||
|
|
@ -1427,6 +1433,9 @@ func (p *PortalProtocol) handleOfferedContents(id enode.ID, keys [][]byte, paylo
|
|||
|
||||
p.contentQueue <- contentElement
|
||||
|
||||
if metrics.Enabled {
|
||||
p.portalMetrics.contentValidated.Inc(1)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,9 @@ type portalMetrics struct {
|
|||
utpOutFailTx metrics.Counter
|
||||
utpOutFailShutdown metrics.Counter
|
||||
utpOutSuccess metrics.Counter
|
||||
|
||||
contentValidated metrics.Counter
|
||||
contentInvalidated metrics.Counter
|
||||
}
|
||||
|
||||
func newPortalMetrics(protocolName string) *portalMetrics {
|
||||
|
|
@ -58,5 +61,7 @@ func newPortalMetrics(protocolName string) *portalMetrics {
|
|||
utpOutFailTx: metrics.NewRegisteredCounter("portal/"+protocolName+"/utp/outbound/fail_tx", nil),
|
||||
utpOutFailShutdown: metrics.NewRegisteredCounter("portal/"+protocolName+"/utp/outbound/fail_shutdown", nil),
|
||||
utpOutSuccess: metrics.NewRegisteredCounter("portal/"+protocolName+"/utp/outbound/success", nil),
|
||||
contentValidated: metrics.NewRegisteredCounter("portal/"+protocolName+"/content/validated", nil),
|
||||
contentInvalidated: metrics.NewRegisteredCounter("portal/"+protocolName+"/content/invalidated", nil),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue