Add lower-level metrics for the number of gossipsub messages sent/received

This commit is contained in:
Zahary Karadjov 2019-10-25 20:15:12 +03:00 committed by zah
parent bb7d892587
commit a6f65cd37e
2 changed files with 26 additions and 9 deletions

View File

@ -23,18 +23,26 @@ const
hasPrompt = not defined(withoutPrompt)
# https://github.com/ethereum/eth2.0-metrics/blob/master/metrics.md#interop-metrics
declareGauge beacon_slot, "Latest slot of the beacon chain state"
declareGauge beacon_head_slot, "Slot of the head block of the beacon chain"
declareGauge beacon_head_root, "Root of the head block of the beacon chain"
declareGauge beacon_slot,
"Latest slot of the beacon chain state"
declareGauge beacon_head_slot,
"Slot of the head block of the beacon chain"
declareGauge beacon_head_root,
"Root of the head block of the beacon chain"
# https://github.com/ethereum/eth2.0-metrics/blob/master/metrics.md#additional-metrics
declareGauge beacon_pending_exits, "Number of pending voluntary exits in local operation pool" # On slot
declareGauge beacon_pending_exits,
"Number of pending voluntary exits in local operation pool" # On slot
# Metrics for tracking attestation and beacon block loss
declareCounter beacon_attestations_sent, "Number of beacon chain attestations sent by this peer"
declareCounter beacon_attestations_received, "Number of beacon chain attestations received by this peer"
declareCounter beacon_blocks_proposed, "Number of beacon chain blocks sent by this peer"
declareCounter beacon_blocks_received, "Number of beacon chain blocks received by this peer"
declareCounter beacon_attestations_sent,
"Number of beacon chain attestations sent by this peer"
declareCounter beacon_attestations_received,
"Number of beacon chain attestations received by this peer"
declareCounter beacon_blocks_proposed,
"Number of beacon chain blocks sent by this peer"
declareCounter beacon_blocks_received,
"Number of beacon chain blocks received by this peer"
logScope: topics = "beacnde"

View File

@ -1,6 +1,6 @@
import
options, tables,
chronos, json_serialization, strutils, chronicles, eth/net/nat,
chronos, json_serialization, strutils, chronicles, metrics, eth/net/nat,
spec/digest, version, conf
const
@ -12,6 +12,13 @@ export
let
globalListeningAddr = parseIpAddress("0.0.0.0")
# Metrics for tracking attestation and beacon block loss
declareCounter gossip_messages_sent,
"Number of gossip messages sent by this peer"
declareCounter gossip_messages_received,
"Number of gossip messages received by this peer"
proc setupNat(conf: BeaconNodeConf): tuple[ip: IpAddress,
tcpPort: Port,
udpPort: Port] =
@ -248,6 +255,7 @@ else:
result = proc(api: DaemonAPI,
ticket: PubsubTicket,
msg: PubSubMessage): Future[bool] {.async.} =
inc gossip_messages_received
trace "Incoming gossip bytes",
peer = msg.peer, len = msg.data.len, tops = msg.topics
msgHandler SSZ.decode(msg.data, MsgType)
@ -259,6 +267,7 @@ else:
discard await node.daemon.pubsubSubscribe(topic, makeMessageHandler(msgHandler))
proc broadcast*(node: Eth2Node, topic: string, msg: auto) =
inc gossip_messages_sent
traceAsyncErrors node.daemon.pubsubPublish(topic, SSZ.encode(msg))
# TODO: