mirror of
https://github.com/status-im/nim-eth.git
synced 2025-03-04 07:30:33 +00:00
add discv5_network_byte metric in discoveryv5 protocol (#767)
This commit is contained in:
parent
c2d47ac20e
commit
be17263b2a
@ -92,6 +92,7 @@ import
|
||||
export
|
||||
results, node, enr, encoding.maxDiscv5PacketSize, encoding.maxDiscv5TalkRespPayload
|
||||
|
||||
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,
|
||||
@ -171,6 +172,10 @@ type
|
||||
|
||||
DiscResult*[T] = Result[T, cstring]
|
||||
|
||||
Direction {.pure.} = enum
|
||||
In = "in"
|
||||
Out = "out"
|
||||
|
||||
const
|
||||
defaultDiscoveryConfig* = DiscoveryConfig(
|
||||
tableIpLimits: DefaultTableIpLimits,
|
||||
@ -275,6 +280,8 @@ proc sendTo(d: Protocol, a: Address, data: seq[byte]): Future[void] {.async: (ra
|
||||
# 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.int64, labelValues = [$Direction.Out])
|
||||
|
||||
proc send*(d: Protocol, a: Address, data: seq[byte]) =
|
||||
asyncSpawn sendTo(d, a, data)
|
||||
|
||||
@ -423,6 +430,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.int64, labelValues = [$Direction.In])
|
||||
|
||||
let decoded = d.codec.decodePacket(a, packet)
|
||||
if decoded.isOk:
|
||||
let packet = decoded[]
|
||||
|
Loading…
x
Reference in New Issue
Block a user