add discv5_network_byte metric in discoveryv5 protocol

This commit is contained in:
Ivan Folgueira Bande 2024-12-23 17:02:51 +01:00
parent bb5cb6a4d0
commit ad8f678657
No known key found for this signature in database
GPG Key ID: 3C117481F89E24A7
1 changed files with 5 additions and 0 deletions

View File

@ -91,6 +91,7 @@ import
export
options, results, node, enr, encoding.maxDiscv5PacketSize
declareCounter discv5_network_bytes, "discv5 traffic", labels = ["direction"]
declareCounter discovery_message_requests_outgoing,
"Discovery protocol outgoing message requests", labels = ["response"]
declareCounter discovery_message_requests_incoming,
@ -276,6 +277,8 @@ proc sendTo(d: Protocol, a: Address, data: seq[byte]): Future[void] {.async.} =
# because of ping failures due to own network connection failure.
warn "Discovery send failed", msg = e.msg, address = $ta
discv5_network_bytes.inc(data.len, labelValues = ["out"])
proc send*(d: Protocol, a: Address, data: seq[byte]) =
asyncSpawn sendTo(d, a, data)
@ -422,6 +425,8 @@ proc sendWhoareyou(d: Protocol, toId: NodeId, a: Address,
debug "Node with this id already has ongoing handshake, ignoring packet"
proc receive*(d: Protocol, a: Address, packet: openArray[byte]) =
discv5_network_bytes.inc(packet.len, labelValues = ["in"])
let decoded = d.codec.decodePacket(a, packet)
if decoded.isOk:
let packet = decoded[]