From eb49d3148c9e37ffa2142e278bc03986ddad70dc Mon Sep 17 00:00:00 2001 From: Ebube Sered Ud Date: Thu, 17 Jun 2021 16:36:44 +0100 Subject: [PATCH] Improve Swap Account Balance Metrics to make use of a Histogram (#628) Modify metrics description Add more buckets to the swap account metrics --- waku/v2/protocol/waku_swap/waku_swap.nim | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/waku/v2/protocol/waku_swap/waku_swap.nim b/waku/v2/protocol/waku_swap/waku_swap.nim index cf307ad85..a31439fcc 100644 --- a/waku/v2/protocol/waku_swap/waku_swap.nim +++ b/waku/v2/protocol/waku_swap/waku_swap.nim @@ -36,9 +36,11 @@ import export waku_swap_types -declarePublicGauge waku_swap_peers, "number of swap peers" +const swapAccountBalanceBuckets = [-Inf, -200.0, -150.0, -100.0, -50.0, 0.0, 50.0, 100.0, 150.0, 200.0, Inf] + +declarePublicGauge waku_swap_peers_count, "number of swap peers" declarePublicGauge waku_swap_errors, "number of swap protocol errors", ["type"] -declarePublicGauge waku_swap_account_state, "swap account state for each peer", ["peer"] +declarePublicHistogram waku_peer_swap_account_balance, "Swap Account Balance for waku peers, aggregated into buckets based on threshold limits", buckets = swapAccountBalanceBuckets logScope: topics = "wakuswap" @@ -194,7 +196,7 @@ proc handleCheque*(ws: WakuSwap, cheque: Cheque) = # Log Account Metrics proc logAccountMetrics*(ws: Wakuswap, peer: PeerId) {.async.}= - waku_swap_account_state.set(ws.accounting[peer].int64, labelValues = [$peer]) + waku_peer_swap_account_balance.observe(ws.accounting[peer].int64) proc init*(wakuSwap: WakuSwap) = @@ -270,6 +272,6 @@ proc init*(T: type WakuSwap, peerManager: PeerManager, rng: ref BrHmacDrbgContex proc setPeer*(ws: WakuSwap, peer: PeerInfo) = ws.peerManager.addPeer(peer, WakuSwapCodec) - waku_swap_peers.inc() + waku_swap_peers_count.inc() # TODO End to end communication